1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 10:22:52 +01:00

Improve character dynamics, step behaviour

This commit is contained in:
Daniel Evans 2015-04-04 21:23:53 +01:00
parent 2f2551bc47
commit 27c6afba31
3 changed files with 8 additions and 5 deletions

View File

@ -60,7 +60,7 @@ private:
VehicleObject* currentVehicle;
size_t currentSeat;
void createActor(const glm::vec3& size = glm::vec3(0.35f, 0.35f, 1.3f));
void createActor(const glm::vec2& size = glm::vec2(0.7f, 0.8f));
void destroyActor();
// Incredibly hacky "move in this direction".

View File

@ -67,7 +67,7 @@ CharacterObject::~CharacterObject()
}
}
void CharacterObject::createActor(const glm::vec3& size)
void CharacterObject::createActor(const glm::vec2& size)
{
if(physCharacter) {
destroyActor();
@ -82,11 +82,13 @@ void CharacterObject::createActor(const glm::vec3& size)
physObject = new btPairCachingGhostObject;
physObject->setUserPointer(this);
physObject->setWorldTransform(tf);
physShape = new btCapsuleShapeZ(size.x, size.z);
physShape = new btCapsuleShapeZ(size.x, size.y);
physObject->setCollisionShape(physShape);
physObject->setCollisionFlags(btCollisionObject::CF_KINEMATIC_OBJECT);
physCharacter = new btKinematicCharacterController(physObject, physShape, 0.1f, 2);
physCharacter->setVelocityForTimeInterval(btVector3(1.f, 1.f, 0.f), 1.f);
physCharacter = new btKinematicCharacterController(physObject, physShape, 0.30f, 2);
physCharacter->setFallSpeed(20.f);
physCharacter->setUseGhostSweepTest(true);
physCharacter->setVelocityForTimeInterval(btVector3(1.f, 1.f, 1.f), 1.f);
physCharacter->setGravity(engine->dynamicsWorld->getGravity().length());
physCharacter->setJumpSpeed(5.f);

View File

@ -107,6 +107,7 @@ RWGame::RWGame(const std::string& gamepath, int argc, char* argv[])
debug = new DebugDraw;
debug->setDebugMode(btIDebugDraw::DBG_DrawWireframe | btIDebugDraw::DBG_DrawConstraints | btIDebugDraw::DBG_DrawConstraintLimits);
debug->setShaderProgram(renderer->worldProg);
engine->dynamicsWorld->setDebugDrawer(debug);
engine->gameData.loadDynamicObjects(gamepath + "/data/object.dat");