aboutsummaryrefslogtreecommitdiff
path: root/src/shared/phys
diff options
context:
space:
mode:
authorAlexander Pickering <alex@cogarr.net>2018-11-07 14:49:35 -0500
committerAlexander Pickering <alex@cogarr.net>2018-11-07 14:50:58 -0500
commit2009501214f3c2e3f8d8b1a06432afdf39276bd5 (patch)
treec6c091a4b6f3f714657930cda4fd485ee1dd3d95 /src/shared/phys
parent112517494847f0c86f58544cbf4c35c9b7712ab1 (diff)
downloadbrokengine-2009501214f3c2e3f8d8b1a06432afdf39276bd5.tar.gz
brokengine-2009501214f3c2e3f8d8b1a06432afdf39276bd5.tar.bz2
brokengine-2009501214f3c2e3f8d8b1a06432afdf39276bd5.zip
Added Kinematic Character Controllers
Diffstat (limited to 'src/shared/phys')
-rw-r--r--src/shared/phys/physcommon.cpp46
-rw-r--r--src/shared/phys/physcommon.hpp4
2 files changed, 37 insertions, 13 deletions
diff --git a/src/shared/phys/physcommon.cpp b/src/shared/phys/physcommon.cpp
index 11f18c9..783f282 100644
--- a/src/shared/phys/physcommon.cpp
+++ b/src/shared/phys/physcommon.cpp
@@ -10,22 +10,43 @@ using namespace std::chrono;
btDiscreteDynamicsWorld* World;
std::list<btRigidBody*> Objects;
+std::list<btKinematicCharacterController*> Chars;
+
+extern void dropRigidBody(btRigidBody* b);
+extern void dropChar(btKinematicCharacterController* a);
// Removes all objects from the world
-void ClearObjects(btDiscreteDynamicsWorld* wr, std::list<btRigidBody*> objs, void(*f)(btRigidBody*)) {
+//void ClearObjects(btDiscreteDynamicsWorld* wr, std::list<btRigidBody*> objs, void(*f)(btRigidBody*)) {
- for(std::list<btRigidBody *>::iterator Iterator = objs.begin(); Iterator != objs.end(); ++Iterator) {
- btRigidBody *Object = *Iterator;
+ //for(std::list<btRigidBody *>::iterator Iterator = objs.begin(); Iterator != objs.end(); ++Iterator) {
+ //btRigidBody *Object = *Iterator;
- if(f){
- (*f)(Object);
- }
+ //if(f){
+ //(*f)(Object);
+ //}
+
+ //// Remove the object from the world
+ //wr->removeRigidBody(Object);
+ //delete Object;
+ //}
+ //objs.clear();
+//}
+void ClearObjects(){
+ for(std::list<btRigidBody *>::iterator itr = Objects.begin(); itr != Objects.end(); ++itr){
+ dropRigidBody(*itr);
+ World->removeRigidBody(*itr);
+ delete *itr;
+ }
+ Objects.clear();
+}
- // Remove the object from the world
- wr->removeRigidBody(Object);
- delete Object;
+void ClearChars(){
+ for(std::list<btKinematicCharacterController *>::iterator itr = Chars.begin(); itr != Chars.end(); ++itr){
+ dropChar(*itr);
+ World->removeVehicle(*itr);
+ delete *itr;
}
- objs.clear();
+ Chars.clear();
}
btBroadphaseInterface* BroadPhase;
@@ -48,8 +69,9 @@ void phys_genesis(){
//printf("Created physics world: %p\n",World);
}
-void phys_shutdown(void(*f)(btRigidBody*)){
- ClearObjects(World,Objects,f);
+void phys_shutdown(){
+ ClearObjects();
+ ClearChars();
printf("cleared objects\n");
delete BroadPhase;
printf("deleted broadphase\n");
diff --git a/src/shared/phys/physcommon.hpp b/src/shared/phys/physcommon.hpp
index 00061ec..dd5fe14 100644
--- a/src/shared/phys/physcommon.hpp
+++ b/src/shared/phys/physcommon.hpp
@@ -1,5 +1,7 @@
#ifndef _shared_physcommon_
+#include <BulletDynamics/Character/btKinematicCharacterController.h>
+#include <BulletCollision/CollisionDispatch/btGhostObject.h>
void gameloop_phys(void(*f)(btRigidBody*));
void phys_genesis();
-void phys_shutdown(void(*f)(btRigidBody*));
+void phys_shutdown();
#endif