diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp index bc839554..e1330eff 100644 --- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp @@ -90,7 +90,7 @@ using namespace DanBias; { for (unsigned int i = 0; i < this->gClients.Size(); i++) { - if(this->gClients[i] ) + if(this->gClients[i] && !this->gClients[i]->IsInvalid()) { this->gClients[i]->UpdateClient(); } @@ -101,7 +101,7 @@ using namespace DanBias; bool returnValue = false; for (unsigned int i = 0; i < this->gClients.Size(); i++) { - if(this->gClients[i]) + if(this->gClients[i] && !this->gClients[i]->IsInvalid()) { this->gClients[i]->GetClient()->Send(message); returnValue = true; @@ -115,7 +115,7 @@ using namespace DanBias; { for (unsigned int i = 0; i < this->gClients.Size(); i++) { - if(this->gClients[i] && this->gClients[i]->GetClient()->GetID() == ID) + if(this->gClients[i] && !this->gClients[i]->IsInvalid() && this->gClients[i]->GetClient()->GetID() == ID) { this->gClients[i]->GetClient()->Send(protocol); return true; diff --git a/Code/Physics/GamePhysics/Implementation/PhysicsAPI_Impl.cpp b/Code/Physics/GamePhysics/Implementation/PhysicsAPI_Impl.cpp index 91886313..b86f3821 100644 --- a/Code/Physics/GamePhysics/Implementation/PhysicsAPI_Impl.cpp +++ b/Code/Physics/GamePhysics/Implementation/PhysicsAPI_Impl.cpp @@ -291,7 +291,7 @@ void API_Impl::UpdateWorld() simpleBody->SetPreviousVelocity(simpleBody->GetLinearVelocity()); } - this->dynamicsWorld->stepSimulation(this->timeStep, 1, this->timeStep); + this->dynamicsWorld->stepSimulation(this->timeStep, 10, this->timeStep); ICustomBody::State state; @@ -314,8 +314,33 @@ void API_Impl::UpdateWorld() ICustomBody* bodyA = (ICustomBody*)obA->getUserPointer(); ICustomBody* bodyB = (ICustomBody*)obB->getUserPointer(); - bodyA->CallSubscription_AfterCollisionResponse(bodyA, bodyB, 0.0f); - bodyB->CallSubscription_AfterCollisionResponse(bodyB, bodyA, 0.0f); + + + int numContacts = contactManifold->getNumContacts(); + for (int j=0;jgetContactPoint(j); + if (pt.getDistance()<0.f) + { + if(bodyA->GetState().mass == 40 && bodyB->GetState().centerPos == Float3::null) + { + const char* breakPoint = "STOP"; + } + if(bodyB->GetState().mass == 40 && bodyA->GetState().centerPos == Float3::null) + { + const char* breakPoint = "STOP"; + } + + const btVector3& ptA = pt.getPositionWorldOnA(); + const btVector3& ptB = pt.getPositionWorldOnB(); + const btVector3& normalOnB = pt.m_normalWorldOnB; + + bodyA->CallSubscription_AfterCollisionResponse(bodyA, bodyB, 0.0f); + bodyB->CallSubscription_AfterCollisionResponse(bodyB, bodyA, 0.0f); + } + } + + } } diff --git a/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp b/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp index fe76ade7..25c57e3b 100644 --- a/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp +++ b/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp @@ -22,6 +22,8 @@ SimpleRigidBody::SimpleRigidBody() this->state.restitutionCoeff = 0.0f; this->state.reach = Float3(0.0f, 0.0f, 0.0f); + this->collisionFlags = 0; + this->afterCollision = NULL; this->onMovement = NULL; @@ -85,7 +87,7 @@ void SimpleRigidBody::SetMotionState(btDefaultMotionState* motionState) void SimpleRigidBody::SetRigidBody(btRigidBody* rigidBody) { this->rigidBody = rigidBody; - + this->collisionFlags = rigidBody->getCollisionFlags(); } void SimpleRigidBody::SetSubscription(EventAction_AfterCollisionResponse function) @@ -421,7 +423,7 @@ void SimpleRigidBody::MoveToLimbo() void SimpleRigidBody::ReleaseFromLimbo() { - this->rigidBody->setCollisionFlags(btCollisionObject::CF_KINEMATIC_OBJECT); + this->rigidBody->setCollisionFlags(this->collisionFlags); } void SimpleRigidBody::SetPreviousVelocity(::Oyster::Math::Float3 velocity) diff --git a/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.h b/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.h index 4d1ec3ce..f3e7e0c6 100644 --- a/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.h +++ b/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.h @@ -93,6 +93,8 @@ namespace Oyster btVector3 raySource[2]; btVector3 rayTarget[2]; btScalar rayLambda[2]; + + int collisionFlags; }; } }