“修改注释”

This commit is contained in:
段平 2023-07-31 14:10:52 +08:00
parent 44571198c1
commit dfd0c57acb

View File

@ -534,7 +534,7 @@ namespace PhysX
TriggerCallBack tmp = new TriggerCallBack(shape, effectType, effectValue, enter, leave); TriggerCallBack tmp = new TriggerCallBack(shape, effectType, effectValue, enter, leave);
_worldUserData.trigger_mgr_.Push(&tmp); _worldUserData.trigger_mgr_.Push(&tmp);
//TODO 这一步删除 c++实现中 make智能指针了 这里会删除外部数据shape //这一步是减少引用次数 和用户数据无关 防止内存泄露
//shape->ReleaseMut(); //shape->ReleaseMut();
return true; return true;
} }
@ -562,7 +562,7 @@ namespace PhysX
PxVec3* hero_position = null) PxVec3* hero_position = null)
{ {
//这一部是错误的 api 有bug 不可以返回指针类型 必须在当前栈对象创建PxGemometry //这一部是错误的 api 有bug 不可以返回指针类型 必须在当前栈对象创建PxGemometry
PxGeometry* geometry = CreateGeometry(shape_type, min_position, max_position); PxGeometry* geometry = CreateGeometry(shape_type, min_position, max_position);
if (geometry == null) if (geometry == null)
@ -640,6 +640,8 @@ namespace PhysX
return null; return null;
} }
//可以简化逻辑 调用新的api 直接设置密度和质量
// add collision mask // add collision mask
if (mass > 0) if (mass > 0)
{ {
@ -766,14 +768,14 @@ namespace PhysX
sceneDesc.filterShader = (void*)(delegate* unmanaged[Cdecl]<UInt32, PxFilterData, UInt32, PxFilterData, PxPairFlags*, void*, UInt32, PxFilterFlags>)callback; sceneDesc.filterShader = (void*)(delegate* unmanaged[Cdecl]<UInt32, PxFilterData, UInt32, PxFilterData, PxPairFlags*, void*, UInt32, PxFilterFlags>)callback;
//sceneDesc.simulationEventCallback = this; //sceneDesc.simulationEventCallback = this;
//TODO 根据自己理解实现 应该就是这么搞。。
delegate*<void*, PxContactPairHeader*, PxContactPair*, uint, void> tmpContact = &onContact; delegate*<void*, PxContactPairHeader*, PxContactPair*, uint, void> tmpContact = &onContact;
_event_call_back->collision_callback = (delegate* unmanaged[Cdecl]<void*, PxContactPairHeader*, PxContactPair*, uint, void>)tmpContact; _event_call_back->collision_callback = (delegate* unmanaged[Cdecl]<void*, PxContactPairHeader*, PxContactPair*, uint, void>)tmpContact;
_event_call_back->collision_user_data = (void*)_event_call_back->collision_callback; //根据需要填写用户数据
_event_call_back->collision_user_data = null;
delegate*<void*, PxTriggerPair*, uint, void> tmpTrigger = &onTrigger; delegate*<void*, PxTriggerPair*, uint, void> tmpTrigger = &onTrigger;
_event_call_back->trigger_callback = (delegate* unmanaged[Cdecl]<void*, PxTriggerPair*, uint, void>)tmpTrigger; _event_call_back->trigger_callback = (delegate* unmanaged[Cdecl]<void*, PxTriggerPair*, uint, void>)tmpTrigger;
_event_call_back->trigger_user_data = (void*)_event_call_back->trigger_callback; _event_call_back->trigger_user_data = null;
//其余方法没有重载 不需要设置回调函数 //其余方法没有重载 不需要设置回调函数
sceneDesc.simulationEventCallback = create_simulation_event_callbacks(_event_call_back); sceneDesc.simulationEventCallback = create_simulation_event_callbacks(_event_call_back);
@ -949,8 +951,6 @@ namespace PhysX
// world 类自身方法 end // world 类自身方法 end
//工具方法 start 既然是工具方法是否可以修改为static 放到common
bool RayTest( bool RayTest(
PxRigidActor* actor, PxVec3 start_position, PxRigidActor* actor, PxVec3 start_position,
PxVec3 normalizedDir, int mask, int group, PxVec3 normalizedDir, int mask, int group,
@ -971,7 +971,6 @@ namespace PhysX
PxQueryFilterCallback* fliterCallBack = create_raycast_filter_callback_func( PxQueryFilterCallback* fliterCallBack = create_raycast_filter_callback_func(
(delegate* unmanaged[Cdecl]<PxRigidActor*, PxFilterData*, PxShape*, uint, void*, PxQueryHitType>)(CB.callback), (void*)&CB.userData); (delegate* unmanaged[Cdecl]<PxRigidActor*, PxFilterData*, PxShape*, uint, void*, PxQueryHitType>)(CB.callback), (void*)&CB.userData);
//根据原意图推测为
bool hasBlock = PxSceneQueryExt_raycastSingle(_worldUserData.px_scene_, &start_position, &normalizedDir, distance, PxHitFlags.Default,rayHit, &filterData, fliterCallBack, null); bool hasBlock = PxSceneQueryExt_raycastSingle(_worldUserData.px_scene_, &start_position, &normalizedDir, distance, PxHitFlags.Default,rayHit, &filterData, fliterCallBack, null);
@ -1014,7 +1013,6 @@ namespace PhysX
//hit_result->actor_ptr = sweepHit.actor; //hit_result->actor_ptr = sweepHit.actor;
return true; return true;
} }
//PxSceneQueryExt_sweepMultiple
return false; return false;
} }
@ -1030,7 +1028,6 @@ namespace PhysX
filterData.flags = PxQueryFlags.Dynamic; filterData.flags = PxQueryFlags.Dynamic;
bool hasOverLap = PxSceneQueryExt_overlapAny(_worldUserData.px_scene_, geometry, shapePose, hitBuffer, null,null); bool hasOverLap = PxSceneQueryExt_overlapAny(_worldUserData.px_scene_, geometry, shapePose, hitBuffer, null,null);
if (hasOverLap ) if (hasOverLap )
{ {
return true; return true;
@ -1127,7 +1124,6 @@ namespace PhysX
public static void onContact(void* userData, PxContactPairHeader* pairHeader, PxContactPair* pairs, UInt32 nbPairs) public static void onContact(void* userData, PxContactPairHeader* pairHeader, PxContactPair* pairs, UInt32 nbPairs)
{ {
if (userData == null) { return; } if (userData == null) { return; }
WorldUserData* _worldUserData = (WorldUserData*)userData; WorldUserData* _worldUserData = (WorldUserData*)userData;
@ -1137,7 +1133,6 @@ namespace PhysX
for (UInt32 i = 0; i < nbPairs; i++) for (UInt32 i = 0; i < nbPairs; i++)
{ {
PxContactPair* cp = &pairs[i]; PxContactPair* cp = &pairs[i];
//TODO:这部分转化需要测试
PhysxObjectType type0 = PxConstValue.PhysxGetUserType((PxRigidActor*)pairHeader->actors[0]); PhysxObjectType type0 = PxConstValue.PhysxGetUserType((PxRigidActor*)pairHeader->actors[0]);
PhysxObjectType type1 = PxConstValue.PhysxGetUserType((PxRigidActor*)pairHeader->actors[1]); PhysxObjectType type1 = PxConstValue.PhysxGetUserType((PxRigidActor*)pairHeader->actors[1]);
@ -1146,13 +1141,10 @@ namespace PhysX
{ {
UInt32 contactCount = cp->contactCount; UInt32 contactCount = cp->contactCount;
if (contactCount < 1) continue; if (contactCount < 1) continue;
//contactPoints.Capacity(contactCount);
//contactPoints.Re
Array.Resize<IntPtr>(ref contactPoints, (int)contactCount); Array.Resize<IntPtr>(ref contactPoints, (int)contactCount);
//structgen_pad0 函数地址 //structgen_pad0 函数地址
fixed (IntPtr* contactPointsPtr = contactPoints) fixed (IntPtr* contactPointsPtr = contactPoints)
{ {
//TODO: 这部分代码需要验证
PxContactPairPoint* conPtr0 = (PxContactPairPoint*)contactPointsPtr->ToPointer(); PxContactPairPoint* conPtr0 = (PxContactPairPoint*)contactPointsPtr->ToPointer();
cp->ExtractContacts(conPtr0, contactCount); cp->ExtractContacts(conPtr0, contactCount);
} }