diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 0b817975..5d1a95ec 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -170,12 +170,12 @@ using namespace GameLogic; void PlayerVLethalObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss, Oyster::Math::Float ExtraDamage) { - int damageDone = 0; - int forceThreashHold = 200000; + Oyster::Math::Float damageDone = 0; + Oyster::Math::Float forceThreashHold = 200000; if(kineticEnergyLoss > forceThreashHold) //should only take damage if the force is high enough { - damageDone = (int)(kineticEnergyLoss * 0.10f); + damageDone = (kineticEnergyLoss * 0.10f); damageDone += ExtraDamage; //player.DamageLife(damageDone); } diff --git a/Code/Game/GameLogic/Game_LevelData.cpp b/Code/Game/GameLogic/Game_LevelData.cpp index 62fb3cc5..903cb959 100644 --- a/Code/Game/GameLogic/Game_LevelData.cpp +++ b/Code/Game/GameLogic/Game_LevelData.cpp @@ -55,7 +55,7 @@ IObjectData* Game::LevelData::GetObjectAt(int ID) const void Game::LevelData::GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray& mem) const { mem.Resize(level->dynamicObjects.Size()); - for(int i = 0; i < level->dynamicObjects.Size(); i++) + for(int i = 0; i < (int)level->dynamicObjects.Size(); i++) { mem[i] = level->dynamicObjects[i]; } diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index 1b725b02..e7a77bbd 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -27,9 +27,7 @@ Game::PlayerData::PlayerData() } Game::PlayerData::PlayerData(int playerID,int teamID) { - Oyster::Physics::ICustomBody* rigidBody; this->player = new Player(); - } Game::PlayerData::~PlayerData() { diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 030f0eca..4d3cf703 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -63,9 +63,9 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody) break; case ObjectSpecialType_RedExplosiveBox: { - int dmg = 50; + Oyster::Math::Float dmg = 50; Oyster::Math::Float force = 50; - int radie = 50; + Oyster::Math::Float radie = 50; gameObj = new ExplosiveCrate(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++, dmg, force, radie); } break; @@ -353,7 +353,7 @@ void Level::InitiateLevel(float radius) int offset = 0; for(int i =0; i< nrOfBoxex; i ++) { - rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 605 + i*5, 10), 5, 0.5f, 0.8f, 0.6f); + rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(0.0f, 605.0f + i*5.0f, 10.0f), 5.0f, 0.5f, 0.8f, 0.6f); this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultCollisionAfter, ObjectSpecialType_StandardBox, idCount++)); } @@ -385,16 +385,16 @@ void Level::InitiateLevel(float radius) }*/ // add crystal - ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 605, 0), 5, 0.5f, 0.8f, 0.6f); + ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(10.0f, 605.0f, 0.0f), 5.0f, 0.5f, 0.8f, 0.6f); this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultCollisionAfter, ObjectSpecialType_StandardBox, idCount++)); // add house - ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(20, 20, 20), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(-50, 590, 0), 0, 0.5f, 0.8f, 0.6f); + ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(20.0f, 20.0f, 20.0f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(-50.0f, 590.0f, 0.0f), 0.0f, 0.5f, 0.8f, 0.6f); this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultCollisionAfter, ObjectSpecialType_Generic, idCount++)); // add jumppad - ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(1, 1, 1), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(4, 600.3, 0), 5, 0.5f, 0.8f, 0.6f); + ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(1.0f, 1.0f, 1.0f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(4.0f, 600.3f, 0.0f), 5.0f, 0.5f, 0.8f, 0.6f); this->staticObjects.Push(new JumpPad(rigidBody_Jumppad, ObjectSpecialType_JumpPad,idCount++ ,Oyster::Math::Float3(0,2000,0))); } @@ -419,7 +419,7 @@ int Level::getNrOfDynamicObj() } Object* Level::GetObj( int ID) const { - for (int i = 0; i < this->dynamicObjects.Size(); i++) + for (int i = 0; i < (int)this->dynamicObjects.Size(); i++) { if(this->dynamicObjects[i]->GetID() == ID) return this->dynamicObjects[i]; diff --git a/Code/Game/GameLogic/LevelLoader/ObjectDefines.h b/Code/Game/GameLogic/LevelLoader/ObjectDefines.h index 01d17c3e..131b2938 100644 --- a/Code/Game/GameLogic/LevelLoader/ObjectDefines.h +++ b/Code/Game/GameLogic/LevelLoader/ObjectDefines.h @@ -52,6 +52,7 @@ namespace GameLogic CollisionGeometryType_Box, CollisionGeometryType_Sphere, CollisionGeometryType_Cylinder, + CollisionGeometryType_TriangleMesh, CollisionGeometryType_Count, CollisionGeometryType_Unknown = -1 @@ -161,6 +162,12 @@ namespace GameLogic float radius; }; + struct BoundingVolumeTriangleMesh : public BoundingVolumeBase + { + //Null terminated + wchar_t* filename; + }; + struct BoundingVolume { CollisionGeometryType geoType; @@ -169,7 +176,16 @@ namespace GameLogic LevelLoaderInternal::BoundingVolumeBox box; LevelLoaderInternal::BoundingVolumeSphere sphere; LevelLoaderInternal::BoundingVolumeCylinder cylinder; + LevelLoaderInternal::BoundingVolumeTriangleMesh triangleMesh; }; + + virtual ~BoundingVolume() + { + if(geoType == CollisionGeometryType_TriangleMesh) + { + delete[] triangleMesh.filename; + } + } }; } diff --git a/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp b/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp index 826a52be..daa62752 100644 --- a/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp +++ b/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp @@ -119,7 +119,7 @@ namespace GameLogic int temp; - for(int i = 0; i < tempSize; i++) + for(int i = 0; i < (int)tempSize; i++) { memcpy(&temp, &buffer[start], 4); start += 4; @@ -175,6 +175,17 @@ namespace GameLogic start += sizeof(volume.cylinder); break; + case CollisionGeometryType_TriangleMesh: + //Get string size + memcpy(&tempSize, &buf[start], sizeof(tempSize)); + start += sizeof(tempSize); + + //Get actual string + volume.triangleMesh.filename = new wchar_t[tempSize+1]; + memcpy(volume.triangleMesh.filename, &buf[start], tempSize); + volume.triangleMesh.filename[tempSize] = '\0'; + break; + default: break; } diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 79f34245..80969b29 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -90,7 +90,7 @@ void Player::BeginFrame() forwardDir.Normalize(); rightDir.Normalize(); Oyster::Math::Float3 walkDirection = Oyster::Math::Float3(0.0, 0.0, 0.0); - Oyster::Math::Float walkSpeed = this->moveSpeed*0.2; + Oyster::Math::Float walkSpeed = this->moveSpeed*0.2f; if (key_forward > 0.001) { @@ -122,7 +122,7 @@ void Player::BeginFrame() if (key_forward <= 0.001 && key_backward <= 0.001 && key_strafeRight <= 0.001 && key_strafeLeft <= 0.001 && key_jump <= 0.001 && this->rigidBody->GetLambda() < 0.7f) { /* Dampen when on the ground and not being moved by the player */ - linearVelocity *= 0.2; + linearVelocity *= 0.2f; this->rigidBody->SetLinearVelocity (linearVelocity); } else diff --git a/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp b/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp index f7cf6cce..4cdb282d 100644 --- a/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp +++ b/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp @@ -300,11 +300,11 @@ Float4x4 SimpleRigidBody::GetView( const ::Oyster::Math::Float3 &offset ) const Float3 SimpleRigidBody::GetGravity() const { - return this->rigidBody->getGravity(); + return (Float3)this->rigidBody->getGravity(); } Float3 SimpleRigidBody::GetLinearVelocity() const { - return this->rigidBody->getLinearVelocity(); + return (Float3)this->rigidBody->getLinearVelocity(); }