diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index bda72073..1249dafa 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -25,18 +25,19 @@ void Level::InitiateLevel(float radius) sbDesc.radius = 8; //radius; sbDesc.mass = 10e12f; //sbDesc.mass = 0; //10^16 - sbDesc.subscription_onCollisionResponse = Level::LevelCollision; - levelObj = new StaticObject(OBJECT_TYPE::OBJECT_TYPE_WORLD); + ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release(); rigidBody->SetCustomTag(levelObj); - API::Instance().AddObject(rigidBody); + ICustomBody::State state; rigidBody->GetState(state); state.SetRestitutionCoeff(0.1); rigidBody->SetState(state); + levelObj = new StaticObject(rigidBody, LevelCollision, OBJECT_TYPE::OBJECT_TYPE_WORLD); + API::Gravity gravityWell; gravityWell.gravityType = API::Gravity::GravityType_Well; diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index bb36246f..35c1765b 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -49,6 +49,17 @@ Object::Object(void* collisionFunc, OBJECT_TYPE type) this->type = type; } +Object::Object(ICustomBody *rigidBody ,void* collisionFunc, OBJECT_TYPE type) +{ + Oyster::Physics::API::Instance().AddObject(rigidBody); + + rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc)); + + this->objectID = GID(); + + this->type = type; +} + void Object::ApplyLinearImpulse(Oyster::Math::Float4 force) { setState.ApplyLinearImpulse(force); diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h index 26bf17db..a4385345 100644 --- a/Code/Game/GameLogic/Object.h +++ b/Code/Game/GameLogic/Object.h @@ -18,6 +18,7 @@ namespace GameLogic public: Object(); Object(void* collisionFunc, OBJECT_TYPE type); + Object(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFunc, OBJECT_TYPE type); ~Object(void); OBJECT_TYPE GetType() const; diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index cdd32090..b24b5bf3 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -18,8 +18,6 @@ Player::Player() lookDir = Oyster::Math::Float4(0,0,-1,0); setState.SetCenterPosition(Oyster::Math::Float4(0,15,0,1)); setState.SetReach(Oyster::Math::Float4(2,3.5,2,0)); - - } Player::~Player(void) diff --git a/Code/Game/GameLogic/StaticObject.cpp b/Code/Game/GameLogic/StaticObject.cpp index 03f33e10..c9fda9cf 100644 --- a/Code/Game/GameLogic/StaticObject.cpp +++ b/Code/Game/GameLogic/StaticObject.cpp @@ -19,6 +19,11 @@ StaticObject::StaticObject(OBJECT_TYPE type) :Object(NULL,type) { +} +StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody,void* collisionFunc, OBJECT_TYPE type) + :Object(rigidBody,collisionFunc,type) +{ + } diff --git a/Code/Game/GameLogic/StaticObject.h b/Code/Game/GameLogic/StaticObject.h index 1a6fd63b..d033f6e8 100644 --- a/Code/Game/GameLogic/StaticObject.h +++ b/Code/Game/GameLogic/StaticObject.h @@ -17,6 +17,7 @@ namespace GameLogic public: StaticObject(); StaticObject(void* collisionFunc, OBJECT_TYPE type); + StaticObject(Oyster::Physics::ICustomBody *rigidBody,void* collisionFunc, OBJECT_TYPE type); StaticObject(OBJECT_TYPE type); ~StaticObject(void);