Skip to content

Commit

Permalink
Merge pull request #486 from hzqst/bulletphysics
Browse files Browse the repository at this point in the history
merge bulletphysics
  • Loading branch information
hzqst authored Aug 27, 2024
2 parents b604ba7 + 8116c16 commit 2a55239
Show file tree
Hide file tree
Showing 33 changed files with 3,477 additions and 2,047 deletions.
642 changes: 642 additions & 0 deletions Build/svencoop/bulletphysics/ConstraintEditDialog.res

Large diffs are not rendered by default.

90 changes: 90 additions & 0 deletions Build/svencoop/bulletphysics/ConstraintPage.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
"bulletphysics/ConstraintPage.res"
{
"ConstraintPage"
{
"ControlName" "PropertyPage"
"fieldName" "ConstraintPage"
"xpos" "0"
"ypos" "28"
"wide" "624"
"tall" "278"
"AutoResize" "0"
"PinCorner" "0"
"visible" "1"
"enabled" "1"
"tabPosition" "0"
"paintbackground" "1"
}
"ConstraintListPanel"
{
"ControlName" "ListPanel"
"fieldName" "ConstraintListPanel"
"xpos" "0"
"ypos" "8"
"wide" "624"
"tall" "226"
"AutoResize" "3"
"PinCorner" "0"
"visible" "1"
"enabled" "1"
"tabPosition" "0"
"paintbackground" "1"
}
"ShiftUpConstraint"
{
"ControlName" "Button"
"fieldName" "ShiftUpConstraint"
"xpos" "240"
"ypos" "244"
"wide" "120"
"tall" "24"
"AutoResize" "0"
"PinCorner" "3"
"visible" "1"
"enabled" "1"
"tabPosition" "1"
"paintbackground" "1"
"labelText" "#BulletPhysics_ShiftUp"
"textAlignment" "west"
"wrap" "0"
"command" "ShiftUpConstraint"
}
"ShiftDownConstraint"
{
"ControlName" "Button"
"fieldName" "ShiftDownConstraint"
"xpos" "360"
"ypos" "244"
"wide" "120"
"tall" "24"
"AutoResize" "0"
"PinCorner" "3"
"visible" "1"
"enabled" "1"
"tabPosition" "1"
"paintbackground" "1"
"labelText" "#BulletPhysics_ShiftDown"
"textAlignment" "west"
"wrap" "0"
"command" "ShiftDownConstraint"
}
"CreateConstraint"
{
"ControlName" "Button"
"fieldName" "CreateConstraint"
"xpos" "480"
"ypos" "244"
"wide" "120"
"tall" "24"
"AutoResize" "0"
"PinCorner" "3"
"visible" "1"
"enabled" "1"
"tabPosition" "1"
"paintbackground" "1"
"labelText" "#BulletPhysics_CreateConstraint"
"textAlignment" "west"
"wrap" "0"
"command" "CreateConstraint"
}
}
Binary file modified Build/svencoop/bulletphysics/bulletphysics_english.txt
Binary file not shown.
Binary file modified Build/svencoop/bulletphysics/bulletphysics_schinese.txt
Binary file not shown.
63 changes: 36 additions & 27 deletions Plugins/BulletPhysics/BaseDynamicObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,43 +330,33 @@ class CBaseDynamicObject : public IDynamicObject

public:

IPhysicRigidBody* FindRigidBodyByName(const std::string& name, bool allowNonNativeRigidBody)
virtual IPhysicRigidBody* FindRigidBodyByName(const std::string& name, bool allowNonNativeRigidBody)
{
return GetRigidBodyByName(name);
}

void CreateRigidBodies(const CDynamicObjectCreationParameter& CreationParam)
virtual void CreateRigidBodies(const CDynamicObjectCreationParameter& CreationParam)
{
for (const auto& pRigidBodyConfig : CreationParam.m_pDynamicObjectConfig->RigidBodyConfigs)
{
auto pRigidBody = CreateRigidBody(CreationParam, pRigidBodyConfig.get(), 0);

if (pRigidBody)
{
ClientPhysicManager()->AddPhysicComponent(pRigidBody->GetPhysicComponentId(), pRigidBody);

CPhysicObjectUpdateContext ObjectUpdateContext;

CPhysicComponentUpdateContext ComponentUpdateContext(&ObjectUpdateContext);

pRigidBody->Update(&ComponentUpdateContext);

m_RigidBodies.emplace_back(pRigidBody);
AddRigidBody(pRigidBody);
}
}
}

void CreateConstraints(const CDynamicObjectCreationParameter& CreationParam)
virtual void CreateConstraints(const CDynamicObjectCreationParameter& CreationParam)
{
for (const auto& pConstraintConfig : CreationParam.m_pDynamicObjectConfig->ConstraintConfigs)
{
auto pConstraint = CreateConstraint(CreationParam, pConstraintConfig.get(), 0);

if (pConstraint)
{
ClientPhysicManager()->AddPhysicComponent(pConstraint->GetPhysicComponentId(), pConstraint);

m_Constraints.emplace_back(pConstraint);
AddConstraint(pConstraint);
}
}
}
Expand All @@ -376,6 +366,32 @@ class CBaseDynamicObject : public IDynamicObject

protected:

void AddRigidBody(IPhysicRigidBody* pRigidBody)
{
ClientPhysicManager()->AddPhysicComponent(pRigidBody->GetPhysicComponentId(), pRigidBody);

CPhysicObjectUpdateContext ObjectUpdateContext;

CPhysicComponentUpdateContext ComponentUpdateContext(&ObjectUpdateContext);

pRigidBody->Update(&ComponentUpdateContext);

m_RigidBodies.emplace_back(pRigidBody);
}

void AddConstraint(IPhysicConstraint* pConstraint)
{
ClientPhysicManager()->AddPhysicComponent(pConstraint->GetPhysicComponentId(), pConstraint);

CPhysicObjectUpdateContext ObjectUpdateContext;

CPhysicComponentUpdateContext ComponentUpdateContext(&ObjectUpdateContext);

pConstraint->Update(&ComponentUpdateContext);

m_Constraints.emplace_back(pConstraint);
}

void RebuildRigidBodies(const CDynamicObjectCreationParameter& CreationParam)
{
std::map<int, int> configIdToComponentIdMap;
Expand All @@ -401,9 +417,7 @@ class CBaseDynamicObject : public IDynamicObject

if (pNewRigidBody)
{
ClientPhysicManager()->AddPhysicComponent(pNewRigidBody->GetPhysicComponentId(), pNewRigidBody);

m_RigidBodies.emplace_back(pNewRigidBody);
AddRigidBody(pNewRigidBody);
}
}
else
Expand All @@ -412,9 +426,7 @@ class CBaseDynamicObject : public IDynamicObject

if (pNewRigidBody)
{
ClientPhysicManager()->AddPhysicComponent(pNewRigidBody->GetPhysicComponentId(), pNewRigidBody);

m_RigidBodies.emplace_back(pNewRigidBody);
AddRigidBody(pNewRigidBody);
}
}
}
Expand All @@ -430,6 +442,7 @@ class CBaseDynamicObject : public IDynamicObject

ClientPhysicManager()->RemovePhysicComponent(pConstraint->GetPhysicComponentId());
}

m_Constraints.clear();

for (const auto& pConstraintConfig : CreationParam.m_pDynamicObjectConfig->ConstraintConfigs)
Expand All @@ -444,9 +457,7 @@ class CBaseDynamicObject : public IDynamicObject

if (pNewConstraint)
{
ClientPhysicManager()->AddPhysicComponent(pNewConstraint->GetPhysicComponentId(), pNewConstraint);

m_Constraints.emplace_back(pNewConstraint);
AddConstraint(pNewConstraint);
}
}
else
Expand All @@ -455,9 +466,7 @@ class CBaseDynamicObject : public IDynamicObject

if (pNewConstraint)
{
ClientPhysicManager()->AddPhysicComponent(pNewConstraint->GetPhysicComponentId(), pNewConstraint);

m_Constraints.emplace_back(pNewConstraint);
AddConstraint(pNewConstraint);
}
}
}
Expand Down
Loading

0 comments on commit 2a55239

Please sign in to comment.