little fixes

This commit is contained in:
Anselme 2016-12-14 11:42:05 +01:00
parent 2a32596873
commit 673fa408f2
4 changed files with 5 additions and 9 deletions

View File

@ -60,9 +60,6 @@ PlayerCharacterNode::PlayerCharacterNode(bool noClip) :
m_noclipMode(noClip), m_noclipMode(noClip),
m_inputActions({NO_ACTION, NO_ACTION, NO_ACTION, NO_ACTION, NO_ACTION}) m_inputActions({NO_ACTION, NO_ACTION, NO_ACTION, NO_ACTION, NO_ACTION})
{ {
m_motionState = new btDefaultMotionState();
// Create the shape // Create the shape
btCollisionShape *shape = new btCapsuleShape(PLAYER_RADIUS, PLAYER_HEIGHT); btCollisionShape *shape = new btCapsuleShape(PLAYER_RADIUS, PLAYER_HEIGHT);
@ -71,7 +68,7 @@ PlayerCharacterNode::PlayerCharacterNode(bool noClip) :
shape->calculateLocalInertia(1.0, localInertia); shape->calculateLocalInertia(1.0, localInertia);
// Create the rigid body object // Create the rigid body object
m_rigidBody = new btRigidBody(1.0, m_motionState, shape, localInertia); m_rigidBody = new btRigidBody(1.0, nullptr, shape, localInertia);
// capsule always pointing up // capsule always pointing up
m_rigidBody->setSleepingThresholds(0.0, 0.0); m_rigidBody->setSleepingThresholds(0.0, 0.0);

View File

@ -34,7 +34,6 @@ public:
class PlayerCharacterNode : public CameraNode class PlayerCharacterNode : public CameraNode
{ {
btRigidBody* m_rigidBody; btRigidBody* m_rigidBody;
btDefaultMotionState *m_motionState;
FirstPersonCamera m_fpsCamera; FirstPersonCamera m_fpsCamera;
bool m_noclipMode; bool m_noclipMode;

View File

@ -151,11 +151,11 @@ int main(){
scene.setMainCamera(trackBallCam); scene.setMainCamera(trackBallCam);
*/ */
// first person player controller // first person player controller
PlayerCharacterNode *player = new PlayerCharacterNode(); PlayerCharacterNode *player = new PlayerCharacterNode(false);
player->setInputs(myKeysMap::MOVE_FORWARD, myKeysMap::MOVE_BACKWARD, myKeysMap::STRAFE_LEFT, myKeysMap::STRAFE_RIGHT, myKeysMap::TOGGLE_NOCLIP); player->setInputs(myKeysMap::MOVE_FORWARD, myKeysMap::MOVE_BACKWARD, myKeysMap::STRAFE_LEFT, myKeysMap::STRAFE_RIGHT, myKeysMap::TOGGLE_NOCLIP);
scene->getRootObject()->addChild(player); scene->getRootObject()->addChild(player);
scene->setMainCamera(player); scene->setMainCamera(player);
player->setPosition(0.f, 10.f, 0.f); player->setPosition(0.f, 15.f, 0.f);
engine.getPhysics()->addRigidBody(player->getRigidbody()); engine.getPhysics()->addRigidBody(player->getRigidbody());
// throw cubes and spheres with mouse clicks // throw cubes and spheres with mouse clicks

View File

@ -118,8 +118,8 @@ void Potator::throwSphere()
glm::vec3 dir(0, 1, 0); glm::vec3 dir(0, 1, 0);
if(m_player != nullptr) if(m_player != nullptr)
{ {
pos = m_player->getEyePosition();
dir = m_player->getDirection(); dir = m_player->getDirection();
pos = m_player->getEyePosition() + dir*2.f;
} }
float throwForce = 20.f; float throwForce = 20.f;