Merge remote-tracking branch 'origin/Physics' into GameLogic

This commit is contained in:
Erik Persson 2014-02-21 15:04:48 +01:00
commit 8e0f6eefda
4 changed files with 37 additions and 8 deletions

View File

@ -90,7 +90,7 @@ using namespace DanBias;
{ {
for (unsigned int i = 0; i < this->gClients.Size(); i++) 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(); this->gClients[i]->UpdateClient();
} }
@ -101,7 +101,7 @@ using namespace DanBias;
bool returnValue = false; bool returnValue = false;
for (unsigned int i = 0; i < this->gClients.Size(); i++) 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); this->gClients[i]->GetClient()->Send(message);
returnValue = true; returnValue = true;
@ -115,7 +115,7 @@ using namespace DanBias;
{ {
for (unsigned int i = 0; i < this->gClients.Size(); i++) 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); this->gClients[i]->GetClient()->Send(protocol);
return true; return true;

View File

@ -291,7 +291,7 @@ void API_Impl::UpdateWorld()
simpleBody->SetPreviousVelocity(simpleBody->GetLinearVelocity()); simpleBody->SetPreviousVelocity(simpleBody->GetLinearVelocity());
} }
this->dynamicsWorld->stepSimulation(this->timeStep, 1, this->timeStep); this->dynamicsWorld->stepSimulation(this->timeStep, 10, this->timeStep);
ICustomBody::State state; ICustomBody::State state;
@ -314,9 +314,34 @@ void API_Impl::UpdateWorld()
ICustomBody* bodyA = (ICustomBody*)obA->getUserPointer(); ICustomBody* bodyA = (ICustomBody*)obA->getUserPointer();
ICustomBody* bodyB = (ICustomBody*)obB->getUserPointer(); ICustomBody* bodyB = (ICustomBody*)obB->getUserPointer();
int numContacts = contactManifold->getNumContacts();
for (int j=0;j<numContacts;j++)
{
btManifoldPoint& pt = contactManifold->getContactPoint(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); bodyA->CallSubscription_AfterCollisionResponse(bodyA, bodyB, 0.0f);
bodyB->CallSubscription_AfterCollisionResponse(bodyB, bodyA, 0.0f); bodyB->CallSubscription_AfterCollisionResponse(bodyB, bodyA, 0.0f);
} }
}
}
} }

View File

@ -22,6 +22,8 @@ SimpleRigidBody::SimpleRigidBody()
this->state.restitutionCoeff = 0.0f; this->state.restitutionCoeff = 0.0f;
this->state.reach = Float3(0.0f, 0.0f, 0.0f); this->state.reach = Float3(0.0f, 0.0f, 0.0f);
this->collisionFlags = 0;
this->afterCollision = NULL; this->afterCollision = NULL;
this->onMovement = NULL; this->onMovement = NULL;
@ -85,7 +87,7 @@ void SimpleRigidBody::SetMotionState(btDefaultMotionState* motionState)
void SimpleRigidBody::SetRigidBody(btRigidBody* rigidBody) void SimpleRigidBody::SetRigidBody(btRigidBody* rigidBody)
{ {
this->rigidBody = rigidBody; this->rigidBody = rigidBody;
this->collisionFlags = rigidBody->getCollisionFlags();
} }
void SimpleRigidBody::SetSubscription(EventAction_AfterCollisionResponse function) void SimpleRigidBody::SetSubscription(EventAction_AfterCollisionResponse function)
@ -421,7 +423,7 @@ void SimpleRigidBody::MoveToLimbo()
void SimpleRigidBody::ReleaseFromLimbo() void SimpleRigidBody::ReleaseFromLimbo()
{ {
this->rigidBody->setCollisionFlags(btCollisionObject::CF_KINEMATIC_OBJECT); this->rigidBody->setCollisionFlags(this->collisionFlags);
} }
void SimpleRigidBody::SetPreviousVelocity(::Oyster::Math::Float3 velocity) void SimpleRigidBody::SetPreviousVelocity(::Oyster::Math::Float3 velocity)

View File

@ -93,6 +93,8 @@ namespace Oyster
btVector3 raySource[2]; btVector3 raySource[2];
btVector3 rayTarget[2]; btVector3 rayTarget[2];
btScalar rayLambda[2]; btScalar rayLambda[2];
int collisionFlags;
}; };
} }
} }