From d7e0b55a82ce3e4538631aaf61c40fae86817a2d Mon Sep 17 00:00:00 2001 From: Robin Engman Date: Fri, 21 Feb 2014 12:21:10 +0100 Subject: [PATCH 1/3] Experiment - Release from limbo --- Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp | 6 ++++-- Code/Physics/GamePhysics/Implementation/SimpleRigidBody.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) 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; }; } } From 1c71d7ef809c75c9ad3a650aebac2edc38410012 Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Fri, 21 Feb 2014 13:54:04 +0100 Subject: [PATCH 2/3] Don't update/send to inavlidated clients --- .../Game/GameServer/Implementation/GameSession_Gameplay.cpp | 6 +++--- Code/Game/GameServer/Implementation/GameSession_General.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp index 1b3f6cb5..6aa8d4c4 100644 --- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp @@ -97,7 +97,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(); } @@ -108,7 +108,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; @@ -122,7 +122,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/Game/GameServer/Implementation/GameSession_General.cpp b/Code/Game/GameServer/Implementation/GameSession_General.cpp index fb4c9246..11e80a9f 100644 --- a/Code/Game/GameServer/Implementation/GameSession_General.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_General.cpp @@ -36,8 +36,8 @@ GameSession::GameSession() this->isCreated = false; this->isRunning = false; this->gameSession = this; - this->logicFrameTime = DELTA_TIME_20; - this->networkFrameTime = DELTA_TIME_20; + this->logicFrameTime = DELTA_TIME_60; + this->networkFrameTime = DELTA_TIME_60; this->networkTimer.reset(); this->logicTimer.reset(); From 954dc67f7a608a3bdd05c007f8c80d44497ffa17 Mon Sep 17 00:00:00 2001 From: Robin Engman Date: Fri, 21 Feb 2014 14:09:38 +0100 Subject: [PATCH 3/3] Fixed multiple collisions --- .../Implementation/GameSession_General.cpp | 4 +-- .../Implementation/PhysicsAPI_Impl.cpp | 31 +++++++++++++++++-- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Code/Game/GameServer/Implementation/GameSession_General.cpp b/Code/Game/GameServer/Implementation/GameSession_General.cpp index fb4c9246..a67f5924 100644 --- a/Code/Game/GameServer/Implementation/GameSession_General.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_General.cpp @@ -36,8 +36,8 @@ GameSession::GameSession() this->isCreated = false; this->isRunning = false; this->gameSession = this; - this->logicFrameTime = DELTA_TIME_20; - this->networkFrameTime = DELTA_TIME_20; + this->logicFrameTime = DELTA_TIME_120; + this->networkFrameTime = DELTA_TIME_120; this->networkTimer.reset(); this->logicTimer.reset(); 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); + } + } + + } }