Merge with Other part of gamelogic(DanbiasGame)

This commit is contained in:
dean11 2013-12-12 14:44:06 +01:00
commit a3e4262c08
52 changed files with 881 additions and 250 deletions

Binary file not shown.

Binary file not shown.

View File

@ -196,6 +196,7 @@ Global
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.ActiveCfg = Debug|Win32
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.Build.0 = Debug|Win32
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.ActiveCfg = Debug|x64
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.Build.0 = Debug|x64
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Mixed Platforms.ActiveCfg = Release|Win32

View File

@ -72,7 +72,7 @@
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
<LibraryPath>$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath)</LibraryPath>
<IncludePath>$(SolutionDir)..\External\Include\;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)Network/NetworkAPI;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
@ -106,7 +106,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)Game/GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -123,12 +123,12 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>GameProtocols_$(PlatformShortName)D.lib;OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
@ -142,14 +142,14 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>GameProtocols_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>OysterGraphics_x86.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
@ -163,14 +163,14 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>GameProtocols_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>OysterGraphics_x86.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
@ -181,6 +181,9 @@
<ProjectReference Include="..\..\Misc\Misc.vcxproj">
<Project>{2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee}</Project>
</ProjectReference>
<ProjectReference Include="..\..\Network\NetworkAPI\NetworkAPI.vcxproj">
<Project>{460d625f-2ac9-4559-b809-0ba89ceaedf4}</Project>
</ProjectReference>
<ProjectReference Include="..\..\OysterGraphics\OysterGraphics.vcxproj">
<Project>{0ec83e64-230e-48ef-b08c-6ac9651b4f82}</Project>
</ProjectReference>

View File

@ -5,6 +5,10 @@
#include "GameClientState/GameClientState.h"
#include "GameClientState\GameState.h"
#include "GameClientState\LobbyState.h"
#include "PlayerProtocols.h"
#include "NetworkClient.h"
#include "L_inputClass.h"
#include "vld.h"
namespace DanBias
@ -12,11 +16,40 @@ namespace DanBias
__int64 DanBiasGame::cntsPerSec = 0;
__int64 DanBiasGame::prevTimeStamp = 0;
float DanBiasGame::secsPerCnt = 0;
InputClass* DanBiasGame::inputObj = NULL;
HINSTANCE DanBiasGame::g_hInst = NULL;
HWND DanBiasGame::g_hWnd = NULL;
#pragma region Game Data
struct MyRecieverObject // :public PontusRecieverObject
{
Oyster::Network::NetworkClient nwClient;
static void ProtocolRecieved(Network::CustomNetProtocol* p)
{
int pType = ((*p)[0]).value.netInt;
switch (pType)
{
case protocol_PlayerNavigation:
break;
case protocol_PlayerPosition:
//int x = ((*p)[1]).value.netInt;
//int y = ((*p)[2]).value.netInt;
//int z = ((*p)[3]).value.netInt;
break;
case protocol_ObjectPosition:
// DanBiasGame::protocolRecived();
break;
default:
break;
}
}
};
class DanBiasGamePrivateData
{
@ -32,12 +65,22 @@ namespace DanBias
public:
Client::GameClientState* gameClientState;
InputClass* inputObj;
GameLogic::Protocol_PlayerMovement player_move;
//Oyster::Network::NetworkClient nwClient;
MyRecieverObject r;
// gameClient;
} data;
#pragma endregion
DanBiasGamePrivateData* DanBiasGame::m_data = new DanBiasGamePrivateData();
DanBiasGamePrivateData* DanBiasGame::m_data = new DanBiasGamePrivateData();
void DanBiasGame::protocolRecived()
{
//m_data->gameClientState.setPos()
}
//--------------------------------------------------------------------------------------
// Interface API functions
//--------------------------------------------------------------------------------------
@ -163,8 +206,8 @@ namespace DanBias
//-------------------------------------------------------------------------------------
HRESULT DanBiasGame::InitInput()
{
inputObj = new InputClass;
if(!inputObj->Initialize(g_hInst, g_hWnd, 1024, 768))
m_data->inputObj = new InputClass;
if(!m_data->inputObj->Initialize(g_hInst, g_hWnd, 1024, 768))
{
MessageBox(0, L"Could not initialize the input object.", L"Error", MB_OK);
return E_FAIL;
@ -174,10 +217,10 @@ namespace DanBias
HRESULT DanBiasGame::Update(float deltaTime)
{
inputObj->Update();
m_data->inputObj->Update();
DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same;
state = m_data->gameClientState->Update(deltaTime, inputObj);
state = m_data->gameClientState->Update(deltaTime, m_data->inputObj);
if(state != Client::GameClientState::ClientState_Same)
{
@ -206,7 +249,7 @@ namespace DanBias
HRESULT DanBiasGame::Render(float deltaTime)
{
int isPressed = 0;
if(inputObj->IsKeyPressed(DIK_A))
if(m_data->inputObj->IsKeyPressed(DIK_A))
{
isPressed = 1;
}
@ -224,8 +267,9 @@ namespace DanBias
{
m_data->gameClientState->Release();
delete m_data->gameClientState;
delete m_data->inputObj;
delete m_data;
delete inputObj;
Oyster::Graphics::API::Clean();
return S_OK;

View File

@ -12,6 +12,7 @@ struct GameState::myData
Oyster::Math3D::Float4x4 proj;
C_Object* object[3];
int modelCount;
//Oyster::Network::NetworkClient* nwClient;
gameStateState state;
}privData;
@ -86,6 +87,8 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
case gameStateState_playing:
// read server data
// update objects
// Client.send(obj);
if(KeyInput->IsKeyPressed(DIK_L))
privData->state = GameState::gameStateState_end;
break;

View File

@ -52,11 +52,13 @@ namespace DanBias
static HRESULT Update(float deltaTime);
static HRESULT Render(float deltaTime);
static HRESULT CleanUp();
static void protocolRecived();
private:
static __int64 cntsPerSec;
static __int64 prevTimeStamp;
static float secsPerCnt;
static InputClass* inputObj;
static HINSTANCE g_hInst;
static HWND g_hWnd;
static DanBiasGamePrivateData* m_data;

View File

@ -1,4 +1,5 @@
#include "AttatchmentMassDriver.h"
#include "PhysicsAPI.h"
using namespace GameLogic;
@ -19,11 +20,20 @@ struct AttatchmentMassDriver::PrivateData
AttatchmentMassDriver::AttatchmentMassDriver(void)
{
myData = new PrivateData();
this->owner = 0;
}
AttatchmentMassDriver::AttatchmentMassDriver(Player &owner)
{
myData = new PrivateData();
this->owner = &owner;
}
AttatchmentMassDriver::~AttatchmentMassDriver(void)
{
delete myData;
}
/********************************************************
@ -31,15 +41,33 @@ AttatchmentMassDriver::~AttatchmentMassDriver(void)
********************************************************/
void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &fireInput)
{
//switch case to determin what functionallity to use in the attatchment
switch (fireInput)
{
case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS:
ForcePush(fireInput);
break;
case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS:
ForcePull(fireInput);
break;
}
}
/********************************************************
* This is a specific functionallity of the weapon
* Pushes objects in a cone in front of the weapon when fired
********************************************************/
void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &fireInput)
{
//create coneRigidBody that will then collide with object and push them in the aimed direction
}
/********************************************************
* Pulls the player in the direction he is looking, used for fast movement(kinda like a jetpack)
********************************************************/
void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &fireInput)
{
Oyster::Physics::API::Instance().ApplyForceAt(owner->GetRigidBody(), owner->GetRigidBody()->GetCenter(), owner->GetLookDir() * 100);
}

View File

@ -8,6 +8,7 @@ namespace GameLogic
{
public:
AttatchmentMassDriver(void);
AttatchmentMassDriver(Player &owner);
~AttatchmentMassDriver(void);
@ -15,6 +16,7 @@ namespace GameLogic
private:
void ForcePush(const WEAPON_FIRE &fireInput);
void ForcePull(const WEAPON_FIRE &fireInput);
private:
struct PrivateData;

View File

@ -14,7 +14,7 @@ struct AttatchmentSocket::PrivateData
}
IAttatchment *Attatchment;
IAttatchment *attatchment;
}myData;
@ -30,5 +30,23 @@ AttatchmentSocket::~AttatchmentSocket(void)
IAttatchment* AttatchmentSocket::GetAttatchment()
{
return myData->Attatchment;
return myData->attatchment;
}
void AttatchmentSocket::SetAttatchment(IAttatchment *attatchment)
{
if (myData->attatchment)
{
delete myData->attatchment;
}
myData->attatchment = attatchment;
}
void AttatchmentSocket::RemoveAttatchment()
{
if (myData->attatchment)
{
delete myData->attatchment;
}
}

View File

@ -11,6 +11,8 @@ namespace GameLogic
~AttatchmentSocket(void);
IAttatchment* GetAttatchment();
void SetAttatchment(IAttatchment *attatchment);
void RemoveAttatchment();
private:
struct PrivateData;

View File

@ -1,4 +1,8 @@
#include "CollisionManager.h"
#include "PhysicsAPI.h"
#include "Object.h"
#include "DynamicObject.h"
#include "Player.h"
using namespace Oyster;
@ -8,42 +12,44 @@ namespace GameLogic
namespace CollisionManager
{
void PlayerVBox(Player &player, DynamicObject &box);
Physics::ICustomBody::SubscriptMessage PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj)
{
Player *player = ((Player*)GameLogic::RefManager::getInstance()->GetMap(*rigidBodyPlayer));
Object *realObj = GameLogic::RefManager::getInstance()->GetMap(*obj);
Player *player = ((Player*)(rigidBodyPlayer->gameObjectRef));
Object *realObj = (Object*)obj->gameObjectRef;
switch (realObj->GetType())
{
case Object::OBJECT_TYPE_BOX:
case OBJECT_TYPE_BOX:
PlayerVBox(*player,(*(DynamicObject*) realObj));
break;
case Object::OBJECT_TYPE_PLAYER:
case OBJECT_TYPE_PLAYER:
break;
}
//spela ljud? ta skada? etc etc
return Physics::ICustomBody::SubscriptMessage_none;
}
void PlayerVBox(Player &player, DynamicObject &box)
{
//spela ljud? ta skada? etc etc
player.DamageLife(20);
}
Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj)
{
DynamicObject *box = ((DynamicObject*)GameLogic::RefManager::getInstance()->GetMap(*rigidBodyBox));
Object *realObj = GameLogic::RefManager::getInstance()->GetMap(*obj);
DynamicObject *box = (DynamicObject*)rigidBodyBox->gameObjectRef;
Object *realObj = (Object*)obj->gameObjectRef;
switch (realObj->GetType())
{
case Object::OBJECT_TYPE_BOX:
case OBJECT_TYPE_BOX:
break;
case Object::OBJECT_TYPE_PLAYER:
PlayerVBox(*(Player*)realObj,*box);
case OBJECT_TYPE_PLAYER:
//PlayerVBox(*(Player*)realObj,*box);
break;
}

View File

@ -3,9 +3,6 @@
#include "Object.h"
#include "PhysicsAPI.h"
#include "RefManager.h"
#include "DynamicObject.h"
#include "Player.h"
namespace GameLogic
{
@ -18,8 +15,8 @@ namespace GameLogic
Oyster::Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj);
//these are the specific collision case functions
void PlayerVBox(Player &player, DynamicObject &box);
void BoxVBox(DynamicObject &box1, DynamicObject &box2);
//void PlayerVBox(Player &player, DynamicObject &box);
//void BoxVBox(DynamicObject &box1, DynamicObject &box2);
};

View File

@ -1,29 +1,23 @@
#include "DynamicObject.h"
#include "CollisionManager.h"
using namespace GameLogic;
struct DynamicObject::PrivateData
{
PrivateData()
{
}
~PrivateData()
{
}
}myData;
DynamicObject::DynamicObject()
:Object()
{
myData = new PrivateData();
}
DynamicObject::DynamicObject(void* collisionFunc, OBJECT_TYPE type)
:Object(collisionFunc, type)
{
}
DynamicObject::~DynamicObject(void)
{
delete myData;
}

View File

@ -1,27 +1,24 @@
//////////////////////////////////////////////////
//Created by Erik and Linda of the GameLogic team
//////////////////////////////////////////////////
#ifndef DYNAMICOBJECT_H
#define DYNAMICOBJECT_H
#include "Object.h"
namespace GameLogic
{
class DynamicObject
class DynamicObject : public Object
{
public:
DynamicObject();
DynamicObject(void* collisionFunc, OBJECT_TYPE type);
~DynamicObject(void);
void Update();
private:
struct PrivateData;
PrivateData *myData;
};
}

View File

@ -176,7 +176,6 @@
<ClInclude Include="Level.h" />
<ClInclude Include="Object.h" />
<ClInclude Include="Player.h" />
<ClInclude Include="RefManager.h" />
<ClInclude Include="StaticObject.h" />
<ClInclude Include="Weapon.h" />
</ItemGroup>
@ -191,7 +190,6 @@
<ClCompile Include="Level.cpp" />
<ClCompile Include="Object.cpp" />
<ClCompile Include="Player.cpp" />
<ClCompile Include="RefManager.cpp" />
<ClCompile Include="StaticObject.cpp" />
<ClCompile Include="Weapon.cpp" />
</ItemGroup>

View File

@ -36,6 +36,13 @@ namespace GameLogic
WEAPON_STATE_IDLE = 1,
WEAPON_STATE_RELOADING = 2,
};
}
enum OBJECT_TYPE
{
OBJECT_TYPE_PLAYER = 0,
OBJECT_TYPE_BOX = 1,
OBJECT_TYPE_UNKNOWN = 2,
};
};
#endif

View File

@ -3,22 +3,6 @@
using namespace GameLogic;
struct IAttatchment::PrivateData
{
PrivateData()
{
}
~PrivateData()
{
}
}myData;
IAttatchment::IAttatchment(void)
{
}

View File

@ -1,6 +1,7 @@
#ifndef IATTATCHMENT_H
#define IATTATCHMENT_H
#include "GameLogicStates.h"
#include "Player.h"
namespace GameLogic
{
@ -17,8 +18,9 @@ namespace GameLogic
virtual void UseAttatchment(const WEAPON_FIRE &fireInput) = 0;
private:
struct PrivateData;
PrivateData *myData;
protected:
Player *owner;
};
}

View File

@ -9,14 +9,10 @@ struct Level::PrivateData
{
PrivateData()
{
gameMode = new GameMode();
}
~PrivateData()
{
if (gameMode)
{
delete gameMode;
}
}
@ -40,3 +36,5 @@ Level::~Level(void)
{
delete myData;
}

View File

@ -14,6 +14,8 @@ namespace GameLogic
Level(void);
~Level(void);
void CreateBox();
private:
struct PrivateData;
PrivateData *myData;

View File

@ -1,48 +1,55 @@
#include "Object.h"
#include "OysterMath.h"
#include "DllInterfaces\GFXAPI.h"
#include "CollisionManager.h"
using namespace GameLogic;
using namespace Oyster::Math;
using namespace Oyster::Graphics::Model;
using namespace Utility::DynamicMemory;
using namespace Oyster::Physics;
Object::Object(std::wstring objFile)
Object::Object()
{
//model = new Model();
model = Oyster::Graphics::API::CreateModel(objFile);
API::SimpleBodyDescription sbDesc;
//sbDesc.centerPosition =
//poi
ICustomBody* temp = rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
GameLogic::RefManager::getInstance()->AddMapping(*rigidBody, *this);
rigidBody->gameObjectRef = this;
this->type = OBJECT_TYPE_UNKNOWN;
}
Object::Object(void* collisionFunc, OBJECT_TYPE type)
{
API::SimpleBodyDescription sbDesc;
//sbDesc.centerPosition =
//poi
ICustomBody* temp = rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc));
rigidBody->gameObjectRef = this;
this->type = type;
}
Object::~Object(void)
{
Oyster::Graphics::API::DeleteModel(model);
}
void Object::Render()
{
this->rigidBody->GetOrientation(model->WorldMatrix);
Oyster::Graphics::API::RenderScene(model, 1);
}
Object::OBJECT_TYPE Object::GetType()
OBJECT_TYPE Object::GetType()
{
return this->type;
}
Oyster::Physics::ICustomBody* Object::GetRigidBody()
{
return this->rigidBody;
}

View File

@ -7,11 +7,7 @@
#define OBJECT_H
#include "PhysicsAPI.h"
#include "DllInterfaces/GFXAPI.h"
#include "Model/Model.h"
#include "Utilities.h"
#include "GameLogicStates.h"
namespace GameLogic
@ -19,29 +15,18 @@ namespace GameLogic
class Object
{
public:
enum OBJECT_TYPE
{
OBJECT_TYPE_PLAYER,
OBJECT_TYPE_BOX,
};
Object(std::wstring objFile );
virtual ~Object(void);
void Render();
Object();
Object(void* collisionFunc, OBJECT_TYPE type);
~Object(void);
OBJECT_TYPE GetType();
Oyster::Physics::ICustomBody* GetRigidBody();
private:
OBJECT_TYPE type;
protected:
//either a model pointer or an ID to an arraypos filled with models that are to be rendered
//rigidBody
Oyster::Physics::ICustomBody *rigidBody;
Oyster::Graphics::Model::Model *model;
};
}

View File

@ -15,8 +15,7 @@ struct Player::PrivateData
life = 100;
playerState = PLAYER_STATE_IDLE;
rigidBody->SetSubscription(CollisionManager::PlayerCollision);
lookDir = Oyster::Math::Float3(1,0,0);
}
~PrivateData()
@ -30,16 +29,16 @@ struct Player::PrivateData
int life;
Weapon *weapon;
PLAYER_STATE playerState;
ICustomBody *rigidBody;
Oyster::Math::Float3 lookDir;
}myData;
Player::Player()
:Object(CollisionManager::PlayerCollision, OBJECT_TYPE_PLAYER)
{
myData = new PrivateData();
}
Player::~Player(void)
{
delete myData;
@ -61,12 +60,16 @@ void Player::Update()
********************************************************/
void Player::Move(const PLAYER_MOVEMENT &movement)
{
Oyster::Math::Float3 currentVelocity = rigidBody->GetRigidLinearVelocity();
switch(movement)
{
case PLAYER_MOVEMENT_FORWARD:
API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),myData->lookDir * 100);
break;
case PLAYER_MOVEMENT_BACKWARD:
API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),-myData->lookDir * 100);
break;
case PLAYER_MOVEMENT_LEFT:
@ -83,9 +86,9 @@ void Player::Move(const PLAYER_MOVEMENT &movement)
/********************************************************
* Uses the players weapon based on user input
********************************************************/
void Player::Shoot(const WEAPON_FIRE &fireInput)
void Player::UseWeapon(const WEAPON_FIRE &fireInput)
{
myData->weapon->UseWeapon(fireInput);
myData->weapon->Use(fireInput);
}
/********************************************************
@ -94,7 +97,7 @@ void Player::Shoot(const WEAPON_FIRE &fireInput)
********************************************************/
void Player::Jump()
{
API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),-Oyster::Math::Float3(0,1,0) * 100);
}
bool Player::IsWalking()
@ -112,7 +115,12 @@ bool Player::IsIdle()
Oyster::Math::Float3 Player::GetPos()
{
return myData->rigidBody->GetCenter();
return rigidBody->GetCenter();
}
Oyster::Math::Float3 Player::GetLookDir()
{
return myData->lookDir;
}
/********************************************************
@ -123,3 +131,9 @@ void Player::Respawn()
{
}
void Player::DamageLife(int damage)
{
myData->life -= damage;
}

View File

@ -5,10 +5,11 @@
#define PLAYER_H
#include "GameLogicStates.h"
#include "OysterMath.h"
#include "Object.h"
namespace GameLogic
{
class Player
class Player : public Object
{
public:
@ -17,7 +18,7 @@ namespace GameLogic
void Update();
void Move(const PLAYER_MOVEMENT &movement);
void Shoot(const WEAPON_FIRE &fireInput);
void UseWeapon(const WEAPON_FIRE &fireInput);
void Jump();
bool IsWalking();
@ -25,8 +26,12 @@ namespace GameLogic
bool IsIdle();
Oyster::Math::Float3 GetPos();
Oyster::Math::Float3 GetLookDir();
void Respawn();
void DamageLife(int damage);
private:
struct PrivateData;
PrivateData *myData;

View File

@ -8,7 +8,6 @@
#include<map>
#include "Object.h"
#include "PhysicsAPI.h"
namespace GameLogic
{

View File

@ -2,28 +2,22 @@
using namespace GameLogic;
struct StaticObject::PrivateData
{
PrivateData()
{
}
~PrivateData()
{
}
}myData;
StaticObject::StaticObject()
:Object()
{
myData = new PrivateData();
}
StaticObject::StaticObject(void* collisionFunc, OBJECT_TYPE type)
:Object(collisionFunc,type)
{
}
StaticObject::~StaticObject(void)
{
delete myData;
}

View File

@ -11,16 +11,16 @@
namespace GameLogic
{
class StaticObject
class StaticObject : public Object
{
public:
StaticObject();
StaticObject(void* collisionFunc, OBJECT_TYPE type);
~StaticObject(void);
private:
struct PrivateData;
PrivateData *myData;
};
}

View File

@ -9,20 +9,23 @@ struct Weapon::PrivateData
PrivateData()
{
weaponState = WEAPON_STATE_IDLE;
SelectedAttatchment = new AttatchmentMassDriver();
SelectedAttatchment = 0;
currentNrOfAttatchments = 0;
selectedSocketID = 0;
}
~PrivateData()
{
delete SelectedAttatchment;
}
WEAPON_STATE weaponState;
AttatchmentSocket **attatchmentSockets;
int nrOfAttatchmentSockets;
int MaxNrOfSockets;
int currentNrOfAttatchments;
IAttatchment *SelectedAttatchment;
int selectedSocketID;
}myData;
@ -31,6 +34,17 @@ Weapon::Weapon()
myData = new PrivateData();
}
Weapon::Weapon(int MaxNrOfSockets)
{
myData = new PrivateData();
myData->MaxNrOfSockets = MaxNrOfSockets;
myData->attatchmentSockets = new AttatchmentSocket*[MaxNrOfSockets];
for (int i = 0; i < MaxNrOfSockets; i++)
{
myData->attatchmentSockets[i] = new AttatchmentSocket();
}
}
Weapon::~Weapon(void)
{
@ -40,7 +54,7 @@ Weapon::~Weapon(void)
/********************************************************
* Uses the weapon based on the input given and the current chosen attatchment
********************************************************/
void Weapon::UseWeapon(const WEAPON_FIRE &fireInput)
void Weapon::Use(const WEAPON_FIRE &fireInput)
{
myData->SelectedAttatchment->UseAttatchment(fireInput);
}
@ -67,3 +81,56 @@ bool Weapon::IsReloading()
return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_RELOADING);
}
bool Weapon::IsValidSocket(int socketID)
{
if(socketID < myData->MaxNrOfSockets && socketID >= 0)
{
if (myData->attatchmentSockets[socketID]->GetAttatchment() != 0)
{
return true;
}
}
return false;
}
int Weapon::GetCurrentSocketID()
{
return myData->selectedSocketID;
}
void Weapon::AddNewAttatchment(IAttatchment *attatchment)
{
if(myData->currentNrOfAttatchments < myData->MaxNrOfSockets)
{
myData->attatchmentSockets[myData->currentNrOfAttatchments]->SetAttatchment(attatchment);
myData->currentNrOfAttatchments++;
}
}
void Weapon::SwitchAttatchment(IAttatchment *attatchment, int socketID)
{
if (IsValidSocket(socketID))
{
myData->attatchmentSockets[socketID]->SetAttatchment(attatchment);
}
}
void Weapon::RemoveAttatchment(int socketID)
{
if (IsValidSocket(socketID))
{
myData->attatchmentSockets[socketID]->RemoveAttatchment();
}
}
void Weapon::SelectAttatchment(int socketID)
{
if (IsValidSocket(socketID))
{
myData->SelectedAttatchment = myData->attatchmentSockets[socketID]->GetAttatchment();
myData->selectedSocketID = socketID;
}
}

View File

@ -4,6 +4,8 @@
#ifndef WEAPON_H
#define WEAPON_H
#include "GameLogicStates.h"
#include "IAttatchment.h"
#include "Player.h"
namespace GameLogic
{
@ -15,14 +17,24 @@ namespace GameLogic
Weapon(void);
Weapon(int nrOfAttatchmentSockets);
~Weapon(void);
void UseWeapon(const WEAPON_FIRE &fireInput);
void Use(const WEAPON_FIRE &fireInput);
void AddNewAttatchment(IAttatchment *attatchment, Player *owner);
void SwitchAttatchment(IAttatchment *attatchment, int socketID, Player *owner);
void RemoveAttatchment(int socketID);
void SelectAttatchment(int socketID);
bool IsFireing();
bool IsIdle();
bool IsReloading();
bool IsValidSocket(int socketID);
int GetCurrentSocketID();
private:

View File

@ -154,6 +154,7 @@
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="ObjectProtocols.h" />
<ClInclude Include="PlayerProtocols.h" />
<ClInclude Include="ProtocolIdentificationID.h" />
<ClInclude Include="TEST_PROTOCOLS.h" />

View File

@ -0,0 +1,67 @@
#ifndef GAMELOGIC_PLAYER_PROTOCOLS_H
#define GAMELOGIC_PLAYER_PROTOCOLS_H
#include <CustomNetProtocol.h>
#include "ProtocolIdentificationID.h"
namespace GameLogic
{
struct Protocol_ObjectPosition :public Network::CustomProtocolObject
{
float worldMatrix[16];
// look at dir
Protocol_ObjectPosition()
{
this->protocol[0].value = protocol_PlayerPosition;
this->protocol[0].type = Network::NetAttributeType_Int;
this->protocol[1].type = Network::NetAttributeType_Float;
this->protocol[2].type = Network::NetAttributeType_Float;
this->protocol[3].type = Network::NetAttributeType_Float;
this->protocol[4].type = Network::NetAttributeType_Float;
this->protocol[5].type = Network::NetAttributeType_Float;
this->protocol[6].type = Network::NetAttributeType_Float;
this->protocol[7].type = Network::NetAttributeType_Float;
this->protocol[8].type = Network::NetAttributeType_Float;
this->protocol[9].type = Network::NetAttributeType_Float;
this->protocol[10].type = Network::NetAttributeType_Float;
this->protocol[11].type = Network::NetAttributeType_Float;
this->protocol[12].type = Network::NetAttributeType_Float;
this->protocol[13].type = Network::NetAttributeType_Float;
this->protocol[14].type = Network::NetAttributeType_Float;
this->protocol[15].type = Network::NetAttributeType_Float;
this->protocol[16].type = Network::NetAttributeType_Float;
}
Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = worldMatrix[0];
this->protocol[2].value = worldMatrix[1];
this->protocol[3].value = worldMatrix[2];
this->protocol[4].value = worldMatrix[4];
this->protocol[5].value = worldMatrix[5];
this->protocol[6].value = worldMatrix[6];
this->protocol[7].value = worldMatrix[7];
this->protocol[8].value = worldMatrix[8];
this->protocol[9].value = worldMatrix[9];
this->protocol[10].value = worldMatrix[10];
this->protocol[11].value = worldMatrix[11];
this->protocol[12].value = worldMatrix[12];
this->protocol[13].value = worldMatrix[13];
this->protocol[14].value = worldMatrix[14];
this->protocol[15].value = worldMatrix[15];
this->protocol[16].value = worldMatrix[16];
return &protocol;
}
private:
Network::CustomNetProtocol protocol;
};
}
#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H

View File

@ -50,6 +50,35 @@ namespace GameLogic
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_PlayerPosition :public Network::CustomProtocolObject
{
float position[3];
// look at dir
Protocol_PlayerPosition()
{
this->protocol[0].value = protocol_PlayerPosition;
this->protocol[0].type = Network::NetAttributeType_Int;
this->protocol[1].type = Network::NetAttributeType_Float;
this->protocol[2].type = Network::NetAttributeType_Float;
this->protocol[3].type = Network::NetAttributeType_Float;
}
Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = position[0];
this->protocol[2].value = position[1];
this->protocol[3].value = position[2];
return &protocol;
}
private:
Network::CustomNetProtocol protocol;
};
}
#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H

View File

@ -4,6 +4,8 @@
/* THERE CAN ABSOLUTLEY NOT BE TWO DEFINITIONS WITH THE SAME ID!! */
#define protocol_PlayerNavigation 0
#define protocol_PlayerPosition 1
#define protocol_ObjectPosition 2
#define PROTOCOL_TEST 2

View File

@ -91,9 +91,12 @@
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_WINDLL;PHYSICS_DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<GenerateXMLDocumentationFiles>false</GenerateXMLDocumentationFiles>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ModuleDefinitionFile>
</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -102,9 +105,12 @@
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_WINDLL;PHYSICS_DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<GenerateXMLDocumentationFiles>false</GenerateXMLDocumentationFiles>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ModuleDefinitionFile>
</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -115,11 +121,14 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_WINDLL;PHYSICS_DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<GenerateXMLDocumentationFiles>false</GenerateXMLDocumentationFiles>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>
</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -130,11 +139,14 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_WINDLL;PHYSICS_DLL_EXPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<GenerateXMLDocumentationFiles>false</GenerateXMLDocumentationFiles>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>
</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
@ -154,6 +166,8 @@
<ClInclude Include="Implementation\SimpleRigidBody.h" />
<ClInclude Include="Implementation\SphericalRigidBody.h" />
<ClInclude Include="PhysicsAPI.h" />
<ClInclude Include="PhysicsStructs-Impl.h" />
<ClInclude Include="PhysicsStructs.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Implementation\Octree.cpp" />

View File

@ -36,6 +36,12 @@
<ClInclude Include="Implementation\Octree.h">
<Filter>Header Files\Implementation</Filter>
</ClInclude>
<ClInclude Include="PhysicsStructs.h">
<Filter>Header Files\Include</Filter>
</ClInclude>
<ClInclude Include="PhysicsStructs-Impl.h">
<Filter>Header Files\Include</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Implementation\PhysicsAPI_Impl.cpp">

View File

@ -39,7 +39,7 @@ void Octree::AddObject(UniquePointer< ICustomBody > customBodyRef)
data.next = NULL;
data.prev = NULL;
data.customBodyRef = customBodyRef;
this->mapReferences.insert(std::pair <ICustomBody*, unsigned int> (customBodyRef, this->leafData.size()));
this->mapReferences.insert(std::pair <ICustomBody*, unsigned int> (data.customBodyRef, this->leafData.size()));
this->leafData.push_back(data);
/*if(tempPtr != NULL)
@ -184,6 +184,7 @@ unsigned int Octree::GetTemporaryReferenceOf( const ICustomBody* objRef ) const
void Octree::SetAsAltered( unsigned int tempRef )
{
this->leafData[tempRef].container = this->leafData[tempRef].customBodyRef->GetBoundingSphere();
//! @todo TODO: implement stub
}

View File

@ -20,36 +20,36 @@ namespace
float deltaWhen;
Float3 worldWhere;
if( deuter->Intersects(*deuter, 1.0f, deltaWhen, worldWhere) )
if( proto->Intersects(*deuter, 1.0f, deltaWhen, worldWhere) )
{
proto->CallSubscription( proto, deuter );
}
}
}
Float4x4 & MomentOfInertia::CreateSphereMatrix( const Float mass, const Float radius)
Float4x4 & MomentOfInertia::CreateSphereMatrix( const Float mass, const Float radius, ::Oyster::Math::Float4x4 &targetMem )
{
return Formula::MomentOfInertia::Sphere(mass, radius);
return targetMem = Formula::MomentOfInertia::Sphere(mass, radius);
}
Float4x4 & MomentOfInertia::CreateHollowSphereMatrix( const Float mass, const Float radius)
Float4x4 & MomentOfInertia::CreateHollowSphereMatrix( const Float mass, const Float radius, ::Oyster::Math::Float4x4 &targetMem )
{
return Formula::MomentOfInertia::HollowSphere(mass, radius);
return targetMem = Formula::MomentOfInertia::HollowSphere(mass, radius);
}
Float4x4 & MomentOfInertia::CreateCuboidMatrix( const Float mass, const Float height, const Float width, const Float depth )
Float4x4 & MomentOfInertia::CreateCuboidMatrix( const Float mass, const Float height, const Float width, const Float depth, ::Oyster::Math::Float4x4 &targetMem )
{
return Formula::MomentOfInertia::Cuboid(mass, height, width, depth);
return targetMem = Formula::MomentOfInertia::Cuboid(mass, height, width, depth);
}
Float4x4 & MomentOfInertia::CreateCylinderMatrix( const Float mass, const Float height, const Float radius )
Float4x4 & MomentOfInertia::CreateCylinderMatrix( const Float mass, const Float height, const Float radius, ::Oyster::Math::Float4x4 &targetMem )
{
return Formula::MomentOfInertia::Cylinder(mass, height, radius);
return targetMem = Formula::MomentOfInertia::Cylinder(mass, height, radius);
}
Float4x4 & MomentOfInertia::CreateRodMatrix( const Float mass, const Float length )
Float4x4 & MomentOfInertia::CreateRodMatrix( const Float mass, const Float length, ::Oyster::Math::Float4x4 &targetMem )
{
return Formula::MomentOfInertia::RodCenter(mass, length);
return targetMem = Formula::MomentOfInertia::RodCenter(mass, length);
}
API & API::Instance()

View File

@ -42,6 +42,23 @@ UniquePointer<ICustomBody> SimpleRigidBody::Clone() const
return new SimpleRigidBody( *this );
}
SimpleRigidBody::State SimpleRigidBody::GetState() const
{
return State( this->rigid.box.boundingOffset, this->rigid.box.center, AngularAxis(this->rigid.box.rotation).xyz );
}
SimpleRigidBody::State & SimpleRigidBody::GetState( SimpleRigidBody::State &targetMem ) const
{
return targetMem = State( this->rigid.box.boundingOffset, this->rigid.box.center, AngularAxis(this->rigid.box.rotation).xyz );
}
void SimpleRigidBody::SetState( const SimpleRigidBody::State &state )
{ /** @todo TODO: temporary solution! Need to know it's occtree */
this->rigid.box.boundingOffset = state.GetReach();
this->rigid.box.center = state.GetCenterPosition();
this->rigid.box.rotation = state.GetRotation();
}
void SimpleRigidBody::CallSubscription( const ICustomBody *proto, const ICustomBody *deuter )
{
this->collisionAction( proto, deuter );
@ -107,6 +124,12 @@ Float4x4 & SimpleRigidBody::GetView( Float4x4 &targetMem ) const
return targetMem = this->rigid.GetView();
}
Float3 SimpleRigidBody::GetRigidLinearVelocity() const
{
return this->rigid.GetLinearVelocity();
}
UpdateState SimpleRigidBody::Update( Float timeStepLength )
{
this->rigid.Update_LeapFrog( timeStepLength );
@ -178,3 +201,8 @@ void SimpleRigidBody::SetSize( const Float3 &size )
{
this->rigid.SetSize( size );
}
void SimpleRigidBody::SetMomentum( const Float3 &worldG )
{
this->rigid.SetLinearMomentum( worldG );
}

View File

@ -15,6 +15,11 @@ namespace Oyster { namespace Physics
::Utility::DynamicMemory::UniquePointer<ICustomBody> Clone() const;
State GetState() const;
State & GetState( State &targetMem ) const;
void SetState( const State &state );
::Oyster::Math::Float3 GetRigidLinearVelocity() const;
void CallSubscription( const ICustomBody *proto, const ICustomBody *deuter );
bool IsAffectedByGravity() const;
bool Intersects( const ICustomBody &object, ::Oyster::Math::Float timeStepLength, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const;
@ -41,6 +46,7 @@ namespace Oyster { namespace Physics
void SetRotation( const ::Oyster::Math::Float4x4 &rotation );
void SetOrientation( const ::Oyster::Math::Float4x4 &orientation );
void SetSize( const ::Oyster::Math::Float3 &size );
void SetMomentum( const ::Oyster::Math::Float3 &worldG );
private:
::Oyster::Physics3D::RigidBody rigid;

View File

@ -44,6 +44,23 @@ UniquePointer<ICustomBody> SphericalRigidBody::Clone() const
return new SphericalRigidBody( *this );
}
SphericalRigidBody::State SphericalRigidBody::GetState() const
{
return State( this->rigid.box.boundingOffset, this->rigid.box.center, AngularAxis(this->rigid.box.rotation).xyz );
}
SphericalRigidBody::State & SphericalRigidBody::GetState( SphericalRigidBody::State &targetMem ) const
{
return targetMem = State( this->rigid.box.boundingOffset, this->rigid.box.center, AngularAxis(this->rigid.box.rotation).xyz );
}
void SphericalRigidBody::SetState( const SphericalRigidBody::State &state )
{ /** @todo TODO: temporary solution! Need to know it's occtree */
this->rigid.box.boundingOffset = state.GetReach();
this->rigid.box.center = state.GetCenterPosition();
this->rigid.box.rotation = state.GetRotation();
}
void SphericalRigidBody::CallSubscription( const ICustomBody *proto, const ICustomBody *deuter )
{
this->collisionAction( proto, deuter );
@ -109,6 +126,11 @@ Float4x4 & SphericalRigidBody::GetView( Float4x4 &targetMem ) const
return targetMem = this->rigid.GetView();
}
Float3 SphericalRigidBody::GetRigidLinearVelocity() const
{
return this->rigid.GetLinearVelocity();
}
UpdateState SphericalRigidBody::Update( Float timeStepLength )
{
this->rigid.Update_LeapFrog( timeStepLength );
@ -184,3 +206,8 @@ void SphericalRigidBody::SetSize( const Float3 &size )
this->rigid.SetSize( size );
this->body.radius = 0.5f * Min( Min( size.x, size.y ), size.z ); // inline Min( FloatN )?
}
void SphericalRigidBody::SetMomentum( const Float3 &worldG )
{
this->rigid.SetLinearMomentum( worldG );
}

View File

@ -16,6 +16,11 @@ namespace Oyster { namespace Physics
::Utility::DynamicMemory::UniquePointer<ICustomBody> Clone() const;
State GetState() const;
State & GetState( State &targetMem = State() ) const;
void SetState( const State &state );
::Oyster::Math::Float3 GetRigidLinearVelocity() const;
void CallSubscription( const ICustomBody *proto, const ICustomBody *deuter );
bool IsAffectedByGravity() const;
bool Intersects( const ICustomBody &object, ::Oyster::Math::Float timeStepLength, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const;
@ -42,6 +47,7 @@ namespace Oyster { namespace Physics
void SetRotation( const ::Oyster::Math::Float4x4 &rotation );
void SetOrientation( const ::Oyster::Math::Float4x4 &orientation );
void SetSize( const ::Oyster::Math::Float3 &size );
void SetMomentum( const ::Oyster::Math::Float3 &worldG );
private:
::Oyster::Physics3D::RigidBody rigid;

View File

@ -17,6 +17,13 @@ namespace Oyster
class API;
class ICustomBody;
namespace Struct
{
struct SimpleBodyDescription;
struct SphericalBodyDescription;
struct CustomBodyState;
}
enum UpdateState
{
UpdateState_resting,
@ -31,22 +38,22 @@ namespace Oyster
class PHYSICS_DLL_USAGE MomentOfInertia
{
public:
static ::Oyster::Math::Float4x4 & CreateSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius);
static ::Oyster::Math::Float4x4 & CreateSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() );
static ::Oyster::Math::Float4x4 & CreateHollowSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius);
static ::Oyster::Math::Float4x4 & CreateHollowSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() );
static ::Oyster::Math::Float4x4 & CreateCuboidMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float width, const ::Oyster::Math::Float depth );
static ::Oyster::Math::Float4x4 & CreateCuboidMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float width, const ::Oyster::Math::Float depth, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() );
static ::Oyster::Math::Float4x4 & CreateCylinderMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float radius );
static ::Oyster::Math::Float4x4 & CreateCylinderMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float radius, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() );
static ::Oyster::Math::Float4x4 & CreateRodMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float length );
static ::Oyster::Math::Float4x4 & CreateRodMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float length, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() );
};
class PHYSICS_DLL_USAGE API
{
public:
struct SimpleBodyDescription;
struct SphericalBodyDescription;
typedef Struct::SimpleBodyDescription SimpleBodyDescription;
typedef Struct::SphericalBodyDescription SphericalBodyDescription;
typedef void (*EventAction_Destruction)( ::Utility::DynamicMemory::UniquePointer<ICustomBody> proto );
@ -236,7 +243,15 @@ namespace Oyster
SubscriptMessage_ignore_collision_response
};
/********************************************************
* @param gameObjectRef: a pointer to the object in the game owning the rigid body.
********************************************************/
void* gameObjectRef;
typedef SubscriptMessage (*EventAction_Collision)( const ICustomBody *proto, const ICustomBody *deuter );
typedef Struct::SimpleBodyDescription SimpleBodyDescription;
typedef Struct::SphericalBodyDescription SphericalBodyDescription;
typedef Struct::CustomBodyState State;
virtual ~ICustomBody() {};
@ -251,6 +266,26 @@ namespace Oyster
********************************************************/
virtual void CallSubscription( const ICustomBody *proto, const ICustomBody *deuter ) = 0;
/********************************************************
* @todo TODO: need doc
********************************************************/
virtual State GetState() const = 0;
/********************************************************
* @todo TODO: need doc
********************************************************/
virtual State & GetState( State &targetMem ) const = 0;
/********************************************************
* @return the linear velocity of the rigid body in a vector.
********************************************************/
virtual Math::Float3 GetRigidLinearVelocity() const = 0;
/********************************************************
* @todo TODO: need doc
********************************************************/
virtual void SetState( const State &state ) = 0;
/********************************************************
* @return true if Engine should apply gravity on this object.
********************************************************/
@ -390,49 +425,16 @@ namespace Oyster
* Use API::SetSize(...)
********************************************************/
virtual void SetSize( const ::Oyster::Math::Float3 &size ) = 0;
};
struct API::SimpleBodyDescription
{
::Oyster::Math::Float4x4 rotation;
::Oyster::Math::Float3 centerPosition;
::Oyster::Math::Float3 size;
::Oyster::Math::Float mass;
::Oyster::Math::Float4x4 inertiaTensor;
ICustomBody::EventAction_Collision subscription;
bool ignoreGravity;
SimpleBodyDescription()
{
this->rotation = ::Oyster::Math::Float4x4::identity;
this->centerPosition = ::Oyster::Math::Float3::null;
this->size = ::Oyster::Math::Float3( 1.0f );
this->mass = 12.0f;
this->inertiaTensor = ::Oyster::Math::Float4x4::identity;
this->subscription = NULL;
this->ignoreGravity = false;
}
};
struct API::SphericalBodyDescription
{
::Oyster::Math::Float4x4 rotation;
::Oyster::Math::Float3 centerPosition;
::Oyster::Math::Float radius;
::Oyster::Math::Float mass;
ICustomBody::EventAction_Collision subscription;
bool ignoreGravity;
SphericalBodyDescription()
{
this->rotation = ::Oyster::Math::Float4x4::identity;
this->centerPosition = ::Oyster::Math::Float3::null;
this->radius = 0.5f;
this->mass = 10.0f;
this->subscription = NULL;
this->ignoreGravity = false;
}
/********************************************************
* To not be called if is in Engine
* Use API::?? @todo TODO:
********************************************************/
virtual void SetMomentum( const ::Oyster::Math::Float3 &worldG ) = 0;
};
}
}
#include "PhysicsStructs.h"
#endif

View File

@ -0,0 +1,117 @@
#ifndef PHYSICS_STRUCTS_IMPL_H
#define PHYSICS_STRUCTS_IMPL_H
#include "PhysicsStructs.h"
namespace Oyster { namespace Physics
{
namespace Struct
{
inline SimpleBodyDescription::SimpleBodyDescription()
{
this->rotation = ::Oyster::Math::Float4x4::identity;
this->centerPosition = ::Oyster::Math::Float3::null;
this->size = ::Oyster::Math::Float3( 1.0f );
this->mass = 12.0f;
this->inertiaTensor = ::Oyster::Math::Float4x4::identity;
this->subscription = NULL;
this->ignoreGravity = false;
}
inline SphericalBodyDescription::SphericalBodyDescription()
{
this->rotation = ::Oyster::Math::Float4x4::identity;
this->centerPosition = ::Oyster::Math::Float3::null;
this->radius = 0.5f;
this->mass = 10.0f;
this->subscription = NULL;
this->ignoreGravity = false;
}
inline CustomBodyState::CustomBodyState( const ::Oyster::Math::Float3 &reach, const ::Oyster::Math::Float3 &centerPos, const ::Oyster::Math::Float3 &rotation )
{
this->reach = ::Oyster::Math::Float4( reach, 0.0f );
this->centerPos = ::Oyster::Math::Float4( centerPos, 1.0f );
this->angularAxis = ::Oyster::Math::Float4( rotation, 0.0f );
this->isSpatiallyAltered = this->isDisturbed = false;
}
inline CustomBodyState & CustomBodyState::operator = ( const CustomBodyState &state )
{
this->reach = state.reach;
this->centerPos = state.centerPos;
this->angularAxis = state.angularAxis;
this->isSpatiallyAltered = state.isSpatiallyAltered;
this->isDisturbed = state.isDisturbed;
return *this;
}
inline const ::Oyster::Math::Float4 & CustomBodyState::GetReach() const
{
return this->reach;
}
inline ::Oyster::Math::Float4 CustomBodyState::GetSize() const
{
return 2.0f * this->GetReach();
}
inline const ::Oyster::Math::Float4 & CustomBodyState::GetCenterPosition() const
{
return this->centerPos;
}
inline const ::Oyster::Math::Float4 & CustomBodyState::GetAngularAxis() const
{
return this->angularAxis;
}
inline ::Oyster::Math::Float4x4 CustomBodyState::GetRotation() const
{
return ::Oyster::Math3D::RotationMatrix( this->GetAngularAxis().xyz );
}
inline void CustomBodyState::SetSize( const ::Oyster::Math::Float3 &size )
{
this->SetReach( 0.5f * size );
}
inline void CustomBodyState::SetReach( const ::Oyster::Math::Float3 &halfSize )
{
this->reach.xyz = halfSize;
this->reach = ::Utility::Value::Max( this->reach, ::Oyster::Math::Float4::null );
this->isSpatiallyAltered = this->isDisturbed = true;
}
inline void CustomBodyState::SetCenterPosition( const ::Oyster::Math::Float3 &centerPos )
{
this->centerPos.xyz = centerPos;
this->isSpatiallyAltered = this->isDisturbed = true;
}
inline void CustomBodyState::SetRotation( const ::Oyster::Math::Float3 &angularAxis )
{
this->angularAxis.xyz = angularAxis;
this->isSpatiallyAltered = this->isDisturbed = true;
}
inline void CustomBodyState::SetRotation( const ::Oyster::Math::Float4x4 &rotation )
{
this->SetRotation( ::Oyster::Math3D::AngularAxis(rotation).xyz );
}
inline bool CustomBodyState::IsSpatiallyAltered() const
{
return this->isSpatiallyAltered;
}
inline bool CustomBodyState::IsDisturbed() const
{
return this->isDisturbed;
}
}
} }
#endif

View File

@ -0,0 +1,70 @@
#ifndef PHYSICS_STRUCTS_H
#define PHYSICS_STRUCTS_H
#include "OysterMath.h"
#include "PhysicsAPI.h"
namespace Oyster { namespace Physics
{
namespace Struct
{
struct SimpleBodyDescription
{
::Oyster::Math::Float4x4 rotation;
::Oyster::Math::Float3 centerPosition;
::Oyster::Math::Float3 size;
::Oyster::Math::Float mass;
::Oyster::Math::Float4x4 inertiaTensor;
::Oyster::Physics::ICustomBody::EventAction_Collision subscription;
bool ignoreGravity;
SimpleBodyDescription();
};
struct SphericalBodyDescription
{
::Oyster::Math::Float4x4 rotation;
::Oyster::Math::Float3 centerPosition;
::Oyster::Math::Float radius;
::Oyster::Math::Float mass;
::Oyster::Physics::ICustomBody::EventAction_Collision subscription;
bool ignoreGravity;
SphericalBodyDescription();
};
struct CustomBodyState
{
public:
CustomBodyState( const ::Oyster::Math::Float3 &reach = ::Oyster::Math::Float3::null,
const ::Oyster::Math::Float3 &centerPos = ::Oyster::Math::Float3::null,
const ::Oyster::Math::Float3 &rotation = ::Oyster::Math::Float3::null );
CustomBodyState & operator = ( const CustomBodyState &state );
const ::Oyster::Math::Float4 & GetReach() const;
::Oyster::Math::Float4 GetSize() const;
const ::Oyster::Math::Float4 & GetCenterPosition() const;
const ::Oyster::Math::Float4 & GetAngularAxis() const;
::Oyster::Math::Float4x4 GetRotation() const;
void SetSize( const ::Oyster::Math::Float3 &size );
void SetReach( const ::Oyster::Math::Float3 &halfSize );
void SetCenterPosition( const ::Oyster::Math::Float3 &centerPos );
void SetRotation( const ::Oyster::Math::Float3 &angularAxis );
void SetRotation( const ::Oyster::Math::Float4x4 &rotation );
bool IsSpatiallyAltered() const;
bool IsDisturbed() const;
private:
::Oyster::Math::Float4 reach, centerPos, angularAxis;
bool isSpatiallyAltered, isDisturbed;
};
}
} }
#include "PhysicsStructs-Impl.h"
#endif

View File

@ -11,6 +11,27 @@
#include "Quaternion.h"
#include <math.h>
namespace std
{
template<typename ScalarType>
inline ::LinearAlgebra::Vector2<ScalarType> asin( const ::LinearAlgebra::Vector2<ScalarType> &vec )
{
return ::LinearAlgebra::Vector2<ScalarType>( asin(vec.x), asin(vec.y) );
}
template<typename ScalarType>
inline ::LinearAlgebra::Vector3<ScalarType> asin( const ::LinearAlgebra::Vector3<ScalarType> &vec )
{
return ::LinearAlgebra::Vector3<ScalarType>( asin(vec.x), asin(vec.y), asin(vec.z) );
}
template<typename ScalarType>
inline ::LinearAlgebra::Vector4<ScalarType> asin( const ::LinearAlgebra::Vector4<ScalarType> &vec )
{
return ::LinearAlgebra::Vector4<ScalarType>( asin(vec.x), asin(vec.y), asin(vec.z), asin(vec.w) );
}
}
// x2
template<typename ScalarType>
@ -233,6 +254,18 @@ namespace LinearAlgebra2D
namespace LinearAlgebra3D
{
template<typename ScalarType>
inline ::LinearAlgebra::Vector4<ScalarType> AngularAxis( const ::LinearAlgebra::Matrix3x3<ScalarType> &rotationMatrix )
{
return ::std::asin( ::LinearAlgebra::Vector4<ScalarType>(rotationMatrix.v[1].z, rotationMatrix.v[2].x, rotationMatrix.v[0].y, 1) );
}
template<typename ScalarType>
inline ::LinearAlgebra::Vector4<ScalarType> AngularAxis( const ::LinearAlgebra::Matrix4x4<ScalarType> &rotationMatrix )
{
return ::std::asin( ::LinearAlgebra::Vector4<ScalarType>(rotationMatrix.v[1].z, rotationMatrix.v[2].x, rotationMatrix.v[0].y, 1) );
}
template<typename ScalarType>
inline ::LinearAlgebra::Matrix4x4<ScalarType> & TranslationMatrix( const ::LinearAlgebra::Vector3<ScalarType> &position, ::LinearAlgebra::Matrix4x4<ScalarType> &targetMem = ::LinearAlgebra::Matrix4x4<ScalarType>() )
{
@ -286,7 +319,9 @@ namespace LinearAlgebra3D
template<typename ScalarType>
inline ::LinearAlgebra::Matrix3x3<ScalarType> & RotationMatrix_AxisZ( const ScalarType &radian, ::LinearAlgebra::Matrix3x3<ScalarType> &targetMem = ::LinearAlgebra::Matrix3x3<ScalarType>() )
{ return ::LinearAlgebra2D::RotationMatrix( radian, targetMem ); }
{
return ::LinearAlgebra2D::RotationMatrix( radian, targetMem );
}
template<typename ScalarType>
inline ::LinearAlgebra::Matrix4x4<ScalarType> & RotationMatrix_AxisZ( const ScalarType &radian, ::LinearAlgebra::Matrix4x4<ScalarType> &targetMem = ::LinearAlgebra::Matrix4x4<ScalarType>() )
@ -300,7 +335,21 @@ namespace LinearAlgebra3D
}
template<typename ScalarType>
::LinearAlgebra::Matrix4x4<ScalarType> & RotationMatrix( const ::LinearAlgebra::Vector3<ScalarType> &normalizedAxis, const ScalarType &radian, ::LinearAlgebra::Matrix4x4<ScalarType> &targetMem )
inline ::LinearAlgebra::Matrix4x4<ScalarType> RotationMatrix( const ::LinearAlgebra::Vector3<ScalarType> &angularAxis )
{
ScalarType radian = angularAxis.GetMagnitude();
if( radian != 0 )
{
return RotationMatrix( angularAxis / radian, radian );
}
else
{
return ::LinearAlgebra::Matrix4x4<ScalarType>::identity;
}
}
template<typename ScalarType>
::LinearAlgebra::Matrix4x4<ScalarType> & RotationMatrix( const ::LinearAlgebra::Vector3<ScalarType> &normalizedAxis, const ScalarType &radian, ::LinearAlgebra::Matrix4x4<ScalarType> &targetMem = ::LinearAlgebra::Matrix4x4<ScalarType>() )
{ /// TODO: not verified
ScalarType r = radian * 0.5f,
s = std::sin( r ),

View File

@ -81,20 +81,45 @@ namespace Oyster { namespace Math2D
namespace Oyster { namespace Math3D
{
Float4 AngularAxis( const Float3x3 &rotationMatrix )
{
return ::LinearAlgebra3D::AngularAxis( rotationMatrix );
}
Float4 AngularAxis( const Float4x4 &rotationMatrix )
{
return ::LinearAlgebra3D::AngularAxis( rotationMatrix );
}
Float4x4 & TranslationMatrix( const Float3 &position, Float4x4 &targetMem )
{ return ::LinearAlgebra3D::TranslationMatrix( position, targetMem ); }
{
return ::LinearAlgebra3D::TranslationMatrix( position, targetMem );
}
Float4x4 & RotationMatrix_AxisX( const Float &radian, Float4x4 &targetMem )
{ return ::LinearAlgebra3D::RotationMatrix_AxisX( radian, targetMem ); }
{
return ::LinearAlgebra3D::RotationMatrix_AxisX( radian, targetMem );
}
Float4x4 & RotationMatrix_AxisY( const Float &radian, Float4x4 &targetMem )
{ return ::LinearAlgebra3D::RotationMatrix_AxisY( radian, targetMem ); }
{
return ::LinearAlgebra3D::RotationMatrix_AxisY( radian, targetMem );
}
Float4x4 & RotationMatrix_AxisZ( const Float &radian, Float4x4 &targetMem )
{ return ::LinearAlgebra3D::RotationMatrix_AxisZ( radian, targetMem ); }
{
return ::LinearAlgebra3D::RotationMatrix_AxisZ( radian, targetMem );
}
Float4x4 & RotationMatrix( const Float3 &angularAxis, Float4x4 &targetMem )
{
return targetMem = ::LinearAlgebra3D::RotationMatrix( angularAxis );
}
Float4x4 & RotationMatrix( const Float &radian, const Float3 &normalizedAxis, Float4x4 &targetMem )
{ return ::LinearAlgebra3D::RotationMatrix( normalizedAxis, radian, targetMem ); }
{
return ::LinearAlgebra3D::RotationMatrix( normalizedAxis, radian, targetMem );
}
Float3x3 & InverseRotationMatrix( const Float3x3 &rotation, Float3x3 &targetMem )
{
@ -103,7 +128,8 @@ namespace Oyster { namespace Math3D
Float4x4 & InverseRotationMatrix( const Float4x4 &rotation, Float4x4 &targetMem )
{
return targetMem = ::LinearAlgebra3D::InverseRotationMatrix( rotation );
// return targetMem = ::LinearAlgebra3D::InverseRotationMatrix( rotation );
return targetMem = rotation.GetTranspose();
}
Float4x4 & OrientationMatrix( const Float3x3 &rotation, const Float3 &translation, Float4x4 &targetMem )

View File

@ -147,6 +147,12 @@ namespace Oyster { namespace Math3D /// Oyster's native math library specialized
{
using namespace ::Oyster::Math; // deliberate inheritance from ::Oyster::Math namespace
//! Extracts the angularAxis from rotationMatrix
Float4 AngularAxis( const Float3x3 &rotationMatrix );
//! Extracts the angularAxis from rotationMatrix
Float4 AngularAxis( const Float4x4 &rotationMatrix );
/// Sets and returns targetMem to a translationMatrix with position as translation.
Float4x4 & TranslationMatrix( const Float3 &position, Float4x4 &targetMem = Float4x4() );
@ -159,6 +165,9 @@ namespace Oyster { namespace Math3D /// Oyster's native math library specialized
/// Sets and returns targetMem as an counterclockwise rotation matrix around the global Z-axis
Float4x4 & RotationMatrix_AxisZ( const Float &radian, Float4x4 &targetMem = Float4x4() );
/// Sets and returns targetMem as an counterclockwise rotation matrix around the angularAxis.
Float4x4 & RotationMatrix( const Float3 &angularAxis, Float4x4 &targetMem = Float4x4() );
/// Sets and returns targetMem as an counterclockwise rotation matrix around the normalizedAxis.
/// Please make sure normalizedAxis is normalized.
Float4x4 & RotationMatrix( const Float &radian, const Float3 &normalizedAxis, Float4x4 &targetMem = Float4x4() );

View File

@ -393,8 +393,8 @@ namespace Oyster { namespace Collision3D { namespace Utility
bool Intersect( const BoxAxisAligned &box, const Sphere &sphere )
{ // by Dan Andersson
Float3 e = Max( box.minVertex - sphere.center, Float3::null );
e += Max( sphere.center - box.maxVertex, Float3::null );
Float4 e = Max( Float4(box.minVertex - sphere.center, 0.0f), Float4::null );
e += Max( Float4(sphere.center - box.maxVertex, 0.0f), Float4::null );
if( e.Dot(e) > (sphere.radius * sphere.radius) ) return false;
return true;
@ -459,11 +459,11 @@ namespace Oyster { namespace Collision3D { namespace Utility
bool Intersect( const Box &box, const Sphere &sphere )
{ // by Dan Andersson
Float3 e = sphere.center - box.center,
centerL = Float3( e.Dot(box.xAxis), e.Dot(box.yAxis), e.Dot(box.zAxis) );
// center: sphere's center in the box's view space
Float4 center = TransformVector( InverseRotationMatrix(box.rotation), Float4(sphere.center - box.center, 0.0f) );
e = Max( (box.boundingOffset + centerL)*=-1.0f, Float3::null );
e += Max( centerL - box.boundingOffset, Float3::null );
Float4 e = Max( Float4(-box.boundingOffset, 0.0f) - center, Float4::null );
e += Max( center - Float4(box.boundingOffset, 0.0f), Float4::null );
if( e.Dot(e) > (sphere.radius * sphere.radius) ) return false;
return true;

View File

@ -38,7 +38,7 @@ bool Point::Intersects( const ICollideable &target ) const
case Type_universe: return true;
case Type_point: return Utility::Intersect( *this, *(Point*)&target );
case Type_ray: return Utility::Intersect( *(Ray*)&target, *this, ((Ray*)&target)->collisionDistance );
case Type_sphere: Utility::Intersect( *(Sphere*)&target, *this );
case Type_sphere: return Utility::Intersect( *(Sphere*)&target, *this );
case Type_plane: return Utility::Intersect( *(Plane*)&target, *this );
//case Type_triangle: return false; // TODO:
case Type_box_axis_aligned: return Utility::Intersect( *(BoxAxisAligned*)&target, *this );

View File

@ -60,7 +60,7 @@ bool Ray::Contains( const ICollideable &target ) const
switch( target.type )
{
case Type_point: return Utility::Intersect( *this, *(Point*)&target, this->collisionDistance );
case Type_ray: Utility::Contains( *this, *(Ray*)&target );
case Type_ray: return Utility::Contains( *this, *(Ray*)&target );
default: return false;
}
}

View File

@ -35,7 +35,7 @@ bool Sphere::Intersects( const ICollideable &target ) const
case Type_universe: return true;
case Type_point: return Utility::Intersect( *this, *(Point*)&target );
case Type_ray: return Utility::Intersect( *this, *(Ray*)&target, ((Ray*)&target)->collisionDistance );
case Type_sphere: Utility::Intersect( *this, *(Sphere*)&target );
case Type_sphere: return Utility::Intersect( *this, *(Sphere*)&target );
case Type_plane: return Utility::Intersect( *(Plane*)&target, *this );
// case Type_triangle: return false; // TODO:
case Type_box_axis_aligned: return Utility::Intersect( *(BoxAxisAligned*)&target, *this );