| @@ -37,8 +37,8 @@ using namespace lol; | |||
| #define HAVE_PHYS_USE_BULLET | |||
| #endif /* HAVE_PHYS_USE_BULLET */ | |||
| #include "Physics/LolPhysics.h" | |||
| #include "Physics/EasyPhysics.h" | |||
| #include "Physics/Include/LolPhysics.h" | |||
| #include "Physics/Include/EasyPhysics.h" | |||
| #include "PhysicObject.h" | |||
| #include "BtPhysTest.h" | |||
| @@ -37,21 +37,23 @@ | |||
| <ItemGroup> | |||
| <ClInclude Include="BtPhysTest.h" /> | |||
| <ClInclude Include="PhysicObject.h" /> | |||
| <ClInclude Include="Physics\EasyPhysics.h" /> | |||
| <ClInclude Include="Physics\LolBtPhysicsIntegration.h" /> | |||
| <ClInclude Include="Physics\LolPhysics.h" /> | |||
| <ClInclude Include="Physics\Include\EasyCharacterController.h" /> | |||
| <ClInclude Include="Physics\Include\EasyConstraint.h" /> | |||
| <ClInclude Include="Physics\Include\EasyPhysics.h" /> | |||
| <ClInclude Include="Physics\Include\LolBtPhysicsIntegration.h" /> | |||
| <ClInclude Include="Physics\Include\LolPhysics.h" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <ClCompile Include="BtPhysTest.cpp" /> | |||
| <ClCompile Include="Physics\EasyPhysics.cpp" /> | |||
| <ClCompile Include="Physics\Src\EasyCharacterController.cpp" /> | |||
| <ClCompile Include="Physics\Src\EasyConstraint.cpp" /> | |||
| <ClCompile Include="Physics\Src\EasyPhysics.cpp" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <ProjectReference Include="$(SolutionDir)\..\..\src\lolcore.vcxproj"> | |||
| <Project>{9e62f2fe-3408-4eae-8238-fd84238ceeda}</Project> | |||
| </ProjectReference> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| </ItemGroup> | |||
| <PropertyGroup Label="Globals"> | |||
| <ProjectGuid>{ee203b88-44cf-4859-9d42-7a1f43fecb52}</ProjectGuid> | |||
| <ConfigurationType>Application</ConfigurationType> | |||
| @@ -72,4 +74,4 @@ | |||
| <ImportGroup Label="ExtensionTargets"> | |||
| <Import Project="$(SolutionDir)\Lol.Fx.targets" /> | |||
| </ImportGroup> | |||
| </Project> | |||
| </Project> | |||
| @@ -2,21 +2,33 @@ | |||
| <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
| <ItemGroup> | |||
| <ClInclude Include="BtPhysTest.h" /> | |||
| <ClInclude Include="Physics\EasyPhysics.h"> | |||
| <Filter>Physics</Filter> | |||
| <ClInclude Include="PhysicObject.h" /> | |||
| <ClInclude Include="Physics\Include\EasyCharacterController.h"> | |||
| <Filter>Physics\Include</Filter> | |||
| </ClInclude> | |||
| <ClInclude Include="Physics\LolPhysics.h"> | |||
| <Filter>Physics</Filter> | |||
| <ClInclude Include="Physics\Include\LolPhysics.h"> | |||
| <Filter>Physics\Include</Filter> | |||
| </ClInclude> | |||
| <ClInclude Include="Physics\LolBtPhysicsIntegration.h"> | |||
| <Filter>Physics</Filter> | |||
| <ClInclude Include="Physics\Include\EasyConstraint.h"> | |||
| <Filter>Physics\Include</Filter> | |||
| </ClInclude> | |||
| <ClInclude Include="Physics\Include\EasyPhysics.h"> | |||
| <Filter>Physics\Include</Filter> | |||
| </ClInclude> | |||
| <ClInclude Include="Physics\Include\LolBtPhysicsIntegration.h"> | |||
| <Filter>Physics\Include</Filter> | |||
| </ClInclude> | |||
| <ClInclude Include="PhysicObject.h" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <ClCompile Include="BtPhysTest.cpp" /> | |||
| <ClCompile Include="Physics\EasyPhysics.cpp"> | |||
| <Filter>Physics</Filter> | |||
| <ClCompile Include="Physics\Src\EasyCharacterController.cpp"> | |||
| <Filter>Physics\Src</Filter> | |||
| </ClCompile> | |||
| <ClCompile Include="Physics\Src\EasyConstraint.cpp"> | |||
| <Filter>Physics\Src</Filter> | |||
| </ClCompile> | |||
| <ClCompile Include="Physics\Src\EasyPhysics.cpp"> | |||
| <Filter>Physics\Src</Filter> | |||
| </ClCompile> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| @@ -26,5 +38,11 @@ | |||
| <Filter Include="Physics"> | |||
| <UniqueIdentifier>{ccecd634-9321-4c49-9471-e9da50dda6d3}</UniqueIdentifier> | |||
| </Filter> | |||
| <Filter Include="Physics\Include"> | |||
| <UniqueIdentifier>{ef37a177-b550-435b-bfb1-a09ca8059137}</UniqueIdentifier> | |||
| </Filter> | |||
| <Filter Include="Physics\Src"> | |||
| <UniqueIdentifier>{7e5d19e0-b2be-46cc-8fa4-f582ecb4318d}</UniqueIdentifier> | |||
| </Filter> | |||
| </ItemGroup> | |||
| </Project> | |||
| @@ -13,7 +13,9 @@ | |||
| #include "core.h" | |||
| #include "easymesh/easymesh.h" | |||
| #include "Physics/EasyPhysics.h" | |||
| #include "Physics/Include/EasyPhysics.h" | |||
| #include "Physics/Include/EasyCharacterController.h" | |||
| #include "Physics/Include/EasyConstraint.h" | |||
| using namespace lol; | |||
| using namespace lol::phys; | |||
| @@ -0,0 +1,82 @@ | |||
| // | |||
| // Lol Engine | |||
| // | |||
| // Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net> | |||
| // (c) 2009-2012 Benjamin Huet <huet.benjamin@gmail.com> | |||
| // This program is free software; you can redistribute it and/or | |||
| // modify it under the terms of the Do What The Fuck You Want To | |||
| // Public License, Version 2, as published by Sam Hocevar. See | |||
| // http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||
| // | |||
| // | |||
| // The EasyPhysic class | |||
| // ------------------ | |||
| // | |||
| #if !defined __EASYCHARACTERCONTROLLER_EASYCHARACTERCONTROLLER_H__ | |||
| #define __EASYCHARACTERCONTROLLER_EASYCHARACTERCONTROLLER_H__ | |||
| #ifdef HAVE_PHYS_USE_BULLET | |||
| #include "core.h" | |||
| #include "EasyPhysics.h" | |||
| #include <BulletDynamics/Character/btKinematicCharacterController.h> | |||
| #endif | |||
| namespace lol | |||
| { | |||
| namespace phys | |||
| { | |||
| class EasyCharacterController : public EasyPhysic | |||
| { | |||
| #ifdef HAVE_PHYS_USE_BULLET | |||
| public: | |||
| EasyCharacterController() : | |||
| EasyPhysic(), | |||
| m_character(NULL) | |||
| { | |||
| m_up_axis = 1; | |||
| } | |||
| ~EasyCharacterController() | |||
| { | |||
| delete m_character; | |||
| } | |||
| virtual void InitBodyToRigid(bool ZeroMassIsKinematic=false); | |||
| virtual void InitBodyToGhost(); | |||
| virtual void AddToSimulation(class Simulation* current_simulation); | |||
| virtual void RemoveFromSimulation(class Simulation* current_simulation); | |||
| virtual void SetMovementForFrame(vec3 const &MoveQuantity); | |||
| protected: | |||
| virtual btGhostObject* GetGhostObject(); | |||
| btPairCachingGhostObject* m_pair_caching_object; | |||
| btKinematicCharacterController* m_character; | |||
| float m_step_height; | |||
| int m_up_axis; | |||
| #else // NO PHYSIC IMPLEMENTATION | |||
| virtual void InitBodyToRigid(bool ZeroMassIsKinematic=false) { } | |||
| virtual void InitBodyToGhost() { } | |||
| virtual void AddToSimulation(class Simulation* current_simulation) { } | |||
| virtual void RemoveFromSimulation(class Simulation* current_simulation) { } | |||
| virtual void SetMovementForFrame(vec3 const &MoveQuantity) { } | |||
| #endif // PHYSIC IMPLEMENTATION | |||
| }; | |||
| } /* namespace phys */ | |||
| } /* namespace lol */ | |||
| #endif /* __EASYCHARACTERCONTROLLER_EASYCHARACTERCONTROLLER_H__ */ | |||
| @@ -14,15 +14,12 @@ | |||
| // ------------------ | |||
| // | |||
| #if !defined __EASYPHYSICS_EASYPHYSICS_H__ | |||
| #define __EASYPHYSICS_EASYPHYSICS_H__ | |||
| #if !defined __EASYCONSTRAINT_EASYCONSTRAINT_H__ | |||
| #define __EASYCONSTRAINT_EASYCONSTRAINT_H__ | |||
| #ifdef HAVE_PHYS_USE_BULLET | |||
| #include "core.h" | |||
| #include <bullet/btBulletDynamicsCommon.h> | |||
| #include <bullet/btBulletCollisionCommon.h> | |||
| #include <bullet/BulletCollision/CollisionDispatch/btGhostObject.h> | |||
| #include <BulletDynamics/Character/btKinematicCharacterController.h> | |||
| #include "EasyPhysics.h" | |||
| #endif | |||
| namespace lol | |||
| @@ -31,141 +28,6 @@ namespace lol | |||
| namespace phys | |||
| { | |||
| class EasyPhysic | |||
| { | |||
| friend class EasyConstraint; | |||
| #ifdef HAVE_PHYS_USE_BULLET | |||
| public: | |||
| EasyPhysic(); | |||
| ~EasyPhysic(); | |||
| virtual void SetShapeToBox(lol::vec3& box_size); | |||
| virtual void SetShapeToSphere(float radius); | |||
| virtual void SetShapeToCone(float radius, float height); | |||
| virtual void SetShapeToCylinder(lol::vec3& cyl_size); | |||
| virtual void SetShapeToCapsule(float radius, float height); | |||
| virtual bool CanChangeCollisionChannel() { return (m_rigid_body == NULL); } | |||
| virtual void SetTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f))); | |||
| virtual void SetMass(float mass); | |||
| virtual void InitBodyToRigid(bool ZeroMassIsKinematic=false); | |||
| virtual void InitBodyToGhost(); | |||
| virtual void AddToSimulation(class Simulation* current_simulation); | |||
| virtual void RemoveFromSimulation(class Simulation* current_simulation); | |||
| virtual mat4 GetTransform(); | |||
| protected: | |||
| virtual void SetLocalInertia(float mass); | |||
| virtual void SetShapeTo(btCollisionShape* collision_shape); | |||
| virtual btGhostObject* GetGhostObject(); | |||
| btCollisionObject* m_collision_object; | |||
| btGhostObject* m_ghost_object; | |||
| btRigidBody* m_rigid_body; | |||
| btVector3 m_local_inertia; | |||
| btCollisionShape* m_collision_shape; | |||
| btConvexShape* m_convex_shape; | |||
| btMotionState* m_motion_state; | |||
| #else // NO PHYSIC IMPLEMENTATION | |||
| public: | |||
| EasyPhysic() { } | |||
| virtual void SetShapeToBox(lol::vec3& BoxSize) { } | |||
| virtual void SetShapeToSphere(float radius) { } | |||
| virtual void SetShapeToCone(float radius, float height) { } | |||
| virtual void SetShapeToCylinder(lol::vec3& cyl_size) { } | |||
| virtual void SetShapeToCapsule(float radius, float height) { } | |||
| virtual bool CanChangeCollisionChannel() { return true; } | |||
| virtual void SetTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f))) { } | |||
| virtual void SetMass(float mass) { } | |||
| virtual void InitBodyToRigid() { } | |||
| virtual void InitBodyToGhost() { } | |||
| virtual void AddToSimulation(class Simulation* current_simulation) { } | |||
| virtual void RemoveFromSimulation(class Simulation* current_simulation) { } | |||
| virtual mat4 GetTransform() { return mat4(1.0f); } | |||
| virtual void InitBodyToGhost() { } | |||
| #endif // PHYSIC IMPLEMENTATION | |||
| public: | |||
| //Sets the collision Group & Mask. | |||
| //Mask can change at runtime, not group ! | |||
| virtual bool SetCollisionChannel(int NewGroup, int NewMask) | |||
| { | |||
| if (CanChangeCollisionChannel()) | |||
| { | |||
| m_collision_group = (1<<NewGroup); | |||
| m_collision_mask = NewMask; | |||
| return true; | |||
| } | |||
| return false; | |||
| } | |||
| int GetCollisionGroup() { return m_collision_group; } | |||
| int GetCollisionMask() { return m_collision_mask; } | |||
| protected: | |||
| lol::mat4 m_local_to_world; | |||
| float m_mass; | |||
| int m_collision_group; | |||
| int m_collision_mask; | |||
| }; | |||
| class EasyCharacterController : public EasyPhysic | |||
| { | |||
| #ifdef HAVE_PHYS_USE_BULLET | |||
| public: | |||
| EasyCharacterController() : | |||
| EasyPhysic(), | |||
| m_character(NULL) | |||
| { | |||
| m_up_axis = 1; | |||
| } | |||
| ~EasyCharacterController() | |||
| { | |||
| delete m_character; | |||
| } | |||
| virtual void InitBodyToRigid(bool ZeroMassIsKinematic=false); | |||
| virtual void InitBodyToGhost(); | |||
| virtual void AddToSimulation(class Simulation* current_simulation); | |||
| virtual void RemoveFromSimulation(class Simulation* current_simulation); | |||
| virtual void SetMovementForFrame(vec3 const &MoveQuantity); | |||
| protected: | |||
| virtual btGhostObject* GetGhostObject(); | |||
| btPairCachingGhostObject* m_pair_caching_object; | |||
| btKinematicCharacterController* m_character; | |||
| float m_step_height; | |||
| int m_up_axis; | |||
| #else // NO PHYSIC IMPLEMENTATION | |||
| virtual void InitBodyToRigid(bool ZeroMassIsKinematic=false) { } | |||
| virtual void InitBodyToGhost() { } | |||
| virtual void AddToSimulation(class Simulation* current_simulation) { } | |||
| virtual void RemoveFromSimulation(class Simulation* current_simulation) { } | |||
| virtual void SetMovementForFrame(vec3 const &MoveQuantity) { } | |||
| #endif // PHYSIC IMPLEMENTATION | |||
| }; | |||
| class EasyConstraint | |||
| { | |||
| #ifdef HAVE_PHYS_USE_BULLET | |||
| @@ -344,5 +206,5 @@ private: | |||
| } /* namespace lol */ | |||
| #endif /* __EASYPHYSICS_EASYPHYSICS_H__ */ | |||
| #endif /* __EASYCONSTRAINT_EASYCONSTRAINT_H__ */ | |||
| @@ -0,0 +1,128 @@ | |||
| // | |||
| // Lol Engine | |||
| // | |||
| // Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net> | |||
| // (c) 2009-2012 Benjamin Huet <huet.benjamin@gmail.com> | |||
| // This program is free software; you can redistribute it and/or | |||
| // modify it under the terms of the Do What The Fuck You Want To | |||
| // Public License, Version 2, as published by Sam Hocevar. See | |||
| // http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||
| // | |||
| // | |||
| // The EasyPhysic class | |||
| // ------------------ | |||
| // | |||
| #if !defined __EASYPHYSICS_EASYPHYSICS_H__ | |||
| #define __EASYPHYSICS_EASYPHYSICS_H__ | |||
| #ifdef HAVE_PHYS_USE_BULLET | |||
| #include "core.h" | |||
| #include <bullet/btBulletDynamicsCommon.h> | |||
| #include <bullet/btBulletCollisionCommon.h> | |||
| #include <bullet/BulletCollision/CollisionDispatch/btGhostObject.h> | |||
| #endif | |||
| namespace lol | |||
| { | |||
| namespace phys | |||
| { | |||
| class EasyPhysic | |||
| { | |||
| friend class EasyConstraint; | |||
| #ifdef HAVE_PHYS_USE_BULLET | |||
| public: | |||
| EasyPhysic(); | |||
| ~EasyPhysic(); | |||
| virtual void SetShapeToBox(lol::vec3& box_size); | |||
| virtual void SetShapeToSphere(float radius); | |||
| virtual void SetShapeToCone(float radius, float height); | |||
| virtual void SetShapeToCylinder(lol::vec3& cyl_size); | |||
| virtual void SetShapeToCapsule(float radius, float height); | |||
| virtual bool CanChangeCollisionChannel() { return (m_rigid_body == NULL); } | |||
| virtual void SetTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f))); | |||
| virtual void SetMass(float mass); | |||
| virtual void InitBodyToRigid(bool ZeroMassIsKinematic=false); | |||
| virtual void InitBodyToGhost(); | |||
| virtual void AddToSimulation(class Simulation* current_simulation); | |||
| virtual void RemoveFromSimulation(class Simulation* current_simulation); | |||
| virtual mat4 GetTransform(); | |||
| protected: | |||
| virtual void SetLocalInertia(float mass); | |||
| virtual void SetShapeTo(btCollisionShape* collision_shape); | |||
| virtual btGhostObject* GetGhostObject(); | |||
| btCollisionObject* m_collision_object; | |||
| btGhostObject* m_ghost_object; | |||
| btRigidBody* m_rigid_body; | |||
| btVector3 m_local_inertia; | |||
| btCollisionShape* m_collision_shape; | |||
| btConvexShape* m_convex_shape; | |||
| btMotionState* m_motion_state; | |||
| #else // NO PHYSIC IMPLEMENTATION | |||
| public: | |||
| EasyPhysic() { } | |||
| virtual void SetShapeToBox(lol::vec3& BoxSize) { } | |||
| virtual void SetShapeToSphere(float radius) { } | |||
| virtual void SetShapeToCone(float radius, float height) { } | |||
| virtual void SetShapeToCylinder(lol::vec3& cyl_size) { } | |||
| virtual void SetShapeToCapsule(float radius, float height) { } | |||
| virtual bool CanChangeCollisionChannel() { return true; } | |||
| virtual void SetTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f))) { } | |||
| virtual void SetMass(float mass) { } | |||
| virtual void InitBodyToRigid() { } | |||
| virtual void InitBodyToGhost() { } | |||
| virtual void AddToSimulation(class Simulation* current_simulation) { } | |||
| virtual void RemoveFromSimulation(class Simulation* current_simulation) { } | |||
| virtual mat4 GetTransform() { return mat4(1.0f); } | |||
| virtual void InitBodyToGhost() { } | |||
| #endif // PHYSIC IMPLEMENTATION | |||
| public: | |||
| //Sets the collision Group & Mask. | |||
| //Mask can change at runtime, not group ! | |||
| virtual bool SetCollisionChannel(int NewGroup, int NewMask) | |||
| { | |||
| if (CanChangeCollisionChannel()) | |||
| { | |||
| m_collision_group = (1<<NewGroup); | |||
| m_collision_mask = NewMask; | |||
| return true; | |||
| } | |||
| return false; | |||
| } | |||
| int GetCollisionGroup() { return m_collision_group; } | |||
| int GetCollisionMask() { return m_collision_mask; } | |||
| protected: | |||
| lol::mat4 m_local_to_world; | |||
| float m_mass; | |||
| int m_collision_group; | |||
| int m_collision_mask; | |||
| }; | |||
| } /* namespace phys */ | |||
| } /* namespace lol */ | |||
| #endif /* __EASYPHYSICS_EASYPHYSICS_H__ */ | |||
| @@ -13,6 +13,7 @@ | |||
| #include <bullet/btBulletCollisionCommon.h> | |||
| #include "LolBtPhysicsIntegration.h" | |||
| #include "EasyPhysics.h" | |||
| #include "EasyConstraint.h" | |||
| #endif | |||
| namespace lol | |||
| @@ -0,0 +1,92 @@ | |||
| // | |||
| // Lol Engine | |||
| // | |||
| // Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net> | |||
| // (c) 2009-2012 Cédric Lecacheur <jordx@free.fr> | |||
| // (c) 2009-2012 Benjamin Huet <huet.benjamin@gmail.com> | |||
| // This program is free software; you can redistribute it and/or | |||
| // modify it under the terms of the Do What The Fuck You Want To | |||
| // Public License, Version 2, as published by Sam Hocevar. See | |||
| // http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||
| // | |||
| #if defined HAVE_CONFIG_H | |||
| # include "config.h" | |||
| #endif | |||
| #include "../Include/LolBtPhysicsIntegration.h" | |||
| #include "../Include/LolPhysics.h" | |||
| #include "../Include/EasyCharacterController.h" | |||
| namespace lol | |||
| { | |||
| namespace phys | |||
| { | |||
| #ifdef HAVE_PHYS_USE_BULLET | |||
| //------------------------------------------------------------------------- | |||
| //EASY_CHARACTER_CONTROLLER | |||
| //-- | |||
| //Deactivated for Character controller | |||
| void EasyCharacterController::InitBodyToRigid(bool ZeroMassIsKinematic) | |||
| { | |||
| } | |||
| //Return correct Ghost Object | |||
| btGhostObject* EasyCharacterController::GetGhostObject() | |||
| { | |||
| return new btPairCachingGhostObject(); | |||
| } | |||
| //Init to Pair caching ghost object, since Character uses that one. | |||
| void EasyCharacterController::InitBodyToGhost() | |||
| { | |||
| EasyPhysic::InitBodyToGhost(); | |||
| m_pair_caching_object = (btPairCachingGhostObject*)m_ghost_object; | |||
| m_ghost_object->setCollisionFlags(btCollisionObject::CF_CHARACTER_OBJECT | m_ghost_object->getCollisionFlags()); | |||
| } | |||
| //Add Physic object to the simulation | |||
| void EasyCharacterController::AddToSimulation(class Simulation* current_simulation) | |||
| { | |||
| EasyPhysic::AddToSimulation(current_simulation); | |||
| btDiscreteDynamicsWorld* dynamics_world = current_simulation->GetWorld(); | |||
| if (dynamics_world) | |||
| { | |||
| if (m_character) | |||
| delete m_character; | |||
| m_character = new btKinematicCharacterController(m_pair_caching_object, m_convex_shape, m_step_height, m_up_axis); | |||
| dynamics_world->addAction(m_character); | |||
| } | |||
| } | |||
| //Remove Physic object to the simulation | |||
| void EasyCharacterController::RemoveFromSimulation(class Simulation* current_simulation) | |||
| { | |||
| EasyPhysic::RemoveFromSimulation(current_simulation); | |||
| btDiscreteDynamicsWorld* dynamics_world = current_simulation->GetWorld(); | |||
| if (dynamics_world) | |||
| { | |||
| if (m_character) | |||
| dynamics_world->removeAction(m_character); | |||
| } | |||
| } | |||
| //Set movement for this frame | |||
| void EasyCharacterController::SetMovementForFrame(vec3 const &MoveQuantity) | |||
| { | |||
| m_character->setWalkDirection(LOL2BT_VEC3(MoveQuantity)); | |||
| } | |||
| #endif // HAVE_PHYS_USE_BULLET | |||
| } /* namespace phys */ | |||
| } /* namespace lol */ | |||
| @@ -0,0 +1,38 @@ | |||
| #include "../Include/LolBtPhysicsIntegration.h" | |||
| #include "../Include/LolPhysics.h" | |||
| #include "../Include/EasyConstraint.h" | |||
| namespace lol | |||
| { | |||
| namespace phys | |||
| { | |||
| #ifdef HAVE_PHYS_USE_BULLET | |||
| //------------------------------------------------------------------------- | |||
| //EASY_CONSTRAINT | |||
| //-- | |||
| void EasyConstraint::AddToSimulation(class Simulation* current_simulation) | |||
| { | |||
| btDiscreteDynamicsWorld* dynamics_world = current_simulation->GetWorld(); | |||
| if (dynamics_world && m_typed_constraint) | |||
| { | |||
| dynamics_world->addConstraint(m_typed_constraint, m_disable_a2b_collision); | |||
| current_simulation->AddToConstraint(this); | |||
| } | |||
| } | |||
| void EasyConstraint::RemoveFromSimulation(class Simulation* current_simulation) | |||
| { | |||
| btDiscreteDynamicsWorld* dynamics_world = current_simulation->GetWorld(); | |||
| if (dynamics_world, m_typed_constraint) | |||
| dynamics_world->removeConstraint(m_typed_constraint); | |||
| } | |||
| #endif // HAVE_PHYS_USE_BULLET | |||
| } /* namespace phys */ | |||
| } /* namespace lol */ | |||
| @@ -14,8 +14,8 @@ | |||
| # include "config.h" | |||
| #endif | |||
| #include "LolBtPhysicsIntegration.h" | |||
| #include "LolPhysics.h" | |||
| #include "../Include/LolBtPhysicsIntegration.h" | |||
| #include "../Include/LolPhysics.h" | |||
| namespace lol | |||
| { | |||
| @@ -254,87 +254,6 @@ void EasyPhysic::SetLocalInertia(float mass) | |||
| m_local_inertia = btVector3(.0f, .0f, .0f); | |||
| } | |||
| //------------------------------------------------------------------------- | |||
| //EASY_CHARACTER_CONTROLLER | |||
| //-- | |||
| //Deactivated for Character controller | |||
| void EasyCharacterController::InitBodyToRigid(bool ZeroMassIsKinematic) | |||
| { | |||
| } | |||
| //Return correct Ghost Object | |||
| btGhostObject* EasyCharacterController::GetGhostObject() | |||
| { | |||
| return new btPairCachingGhostObject(); | |||
| } | |||
| //Init to Pair caching ghost object, since Character uses that one. | |||
| void EasyCharacterController::InitBodyToGhost() | |||
| { | |||
| EasyPhysic::InitBodyToGhost(); | |||
| m_pair_caching_object = (btPairCachingGhostObject*)m_ghost_object; | |||
| m_ghost_object->setCollisionFlags(btCollisionObject::CF_CHARACTER_OBJECT | m_ghost_object->getCollisionFlags()); | |||
| } | |||
| //Add Physic object to the simulation | |||
| void EasyCharacterController::AddToSimulation(class Simulation* current_simulation) | |||
| { | |||
| EasyPhysic::AddToSimulation(current_simulation); | |||
| btDiscreteDynamicsWorld* dynamics_world = current_simulation->GetWorld(); | |||
| if (dynamics_world) | |||
| { | |||
| if (m_character) | |||
| delete m_character; | |||
| m_character = new btKinematicCharacterController(m_pair_caching_object, m_convex_shape, m_step_height, m_up_axis); | |||
| dynamics_world->addAction(m_character); | |||
| } | |||
| } | |||
| //Remove Physic object to the simulation | |||
| void EasyCharacterController::RemoveFromSimulation(class Simulation* current_simulation) | |||
| { | |||
| EasyPhysic::RemoveFromSimulation(current_simulation); | |||
| btDiscreteDynamicsWorld* dynamics_world = current_simulation->GetWorld(); | |||
| if (dynamics_world) | |||
| { | |||
| if (m_character) | |||
| dynamics_world->removeAction(m_character); | |||
| } | |||
| } | |||
| //Set movement for this frame | |||
| void EasyCharacterController::SetMovementForFrame(vec3 const &MoveQuantity) | |||
| { | |||
| m_character->setWalkDirection(LOL2BT_VEC3(MoveQuantity)); | |||
| } | |||
| //------------------------------------------------------------------------- | |||
| //EASY_CONSTRAINT | |||
| //-- | |||
| void EasyConstraint::AddToSimulation(class Simulation* current_simulation) | |||
| { | |||
| btDiscreteDynamicsWorld* dynamics_world = current_simulation->GetWorld(); | |||
| if (dynamics_world && m_typed_constraint) | |||
| { | |||
| dynamics_world->addConstraint(m_typed_constraint, m_disable_a2b_collision); | |||
| current_simulation->AddToConstraint(this); | |||
| } | |||
| } | |||
| void EasyConstraint::RemoveFromSimulation(class Simulation* current_simulation) | |||
| { | |||
| btDiscreteDynamicsWorld* dynamics_world = current_simulation->GetWorld(); | |||
| if (dynamics_world, m_typed_constraint) | |||
| dynamics_world->removeConstraint(m_typed_constraint); | |||
| } | |||
| #endif // HAVE_PHYS_USE_BULLET | |||
| } /* namespace phys */ | |||