Merge branch 'GameLogic' of https://github.com/dean11/Danbias into GameLogic
This commit is contained in:
commit
7b2be02113
|
@ -39,16 +39,16 @@ AttatchmentMassDriver::~AttatchmentMassDriver(void)
|
|||
/********************************************************
|
||||
* Uses the attatchment and will from here switch case the different WEAPON_FIRE's that are to be used
|
||||
********************************************************/
|
||||
void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &fireInput)
|
||||
void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage)
|
||||
{
|
||||
//switch case to determin what functionallity to use in the attatchment
|
||||
switch (fireInput)
|
||||
switch (usage)
|
||||
{
|
||||
case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS:
|
||||
ForcePush(fireInput);
|
||||
ForcePush(usage);
|
||||
break;
|
||||
case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS:
|
||||
ForcePull(fireInput);
|
||||
ForcePull(usage);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &fireInp
|
|||
/********************************************************
|
||||
* Pushes objects in a cone in front of the weapon when fired
|
||||
********************************************************/
|
||||
void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &fireInput)
|
||||
void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage)
|
||||
{
|
||||
//create coneRigidBody that will then collide with object and push them in the aimed direction
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &fireInput)
|
|||
/********************************************************
|
||||
* Pulls the player in the direction he is looking, used for fast movement(kinda like a jetpack)
|
||||
********************************************************/
|
||||
void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &fireInput)
|
||||
void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage)
|
||||
{
|
||||
//Oyster::Physics::API::Instance().ApplyForceAt(owner->GetRigidBody(), owner->GetRigidBody()->GetCenter(), owner->GetLookDir() * 100);
|
||||
}
|
||||
|
|
|
@ -15,26 +15,26 @@ namespace GameLogic
|
|||
~AttatchmentMassDriver(void);
|
||||
|
||||
|
||||
void UseAttatchment(const WEAPON_FIRE &fireInput);
|
||||
void UseAttatchment(const WEAPON_FIRE &usage);
|
||||
|
||||
private:
|
||||
/********************************************************
|
||||
* Pushes objects and players in a cone in front of the player
|
||||
* @param fireInput: allows switching on different functionality in this specific function
|
||||
********************************************************/
|
||||
void ForcePush(const WEAPON_FIRE &fireInput);
|
||||
void ForcePush(const WEAPON_FIRE &usage);
|
||||
|
||||
/********************************************************
|
||||
* Pulls the player forward, this is a movement tool
|
||||
* @param fireInput: allows switching on different functionality in this specific function
|
||||
********************************************************/
|
||||
void ForcePull(const WEAPON_FIRE &fireInput);
|
||||
void ForcePull(const WEAPON_FIRE &usage);
|
||||
|
||||
/********************************************************
|
||||
* Sucks objects towards the player, the player can then pick up an object and throw it as a projectile
|
||||
* @param fireInput: allows switching on different functionality in this specific function
|
||||
********************************************************/
|
||||
void ForceSuck(const WEAPON_FIRE &fireInput);
|
||||
void ForceSuck(const WEAPON_FIRE &usage);
|
||||
|
||||
private:
|
||||
struct PrivateData;
|
||||
|
|
|
@ -55,3 +55,8 @@ using namespace GameLogic;
|
|||
|
||||
return Physics::ICustomBody::SubscriptMessage_none;
|
||||
}
|
||||
|
||||
Oyster::Physics::ICustomBody::SubscriptMessage LevelCollision(const Oyster::Physics::ICustomBody *rigidBodyLevel, const Oyster::Physics::ICustomBody *obj)
|
||||
{
|
||||
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace GameLogic
|
|||
//typedef SubscriptMessage (*EventAction_Collision)( const ICustomBody *proto, const ICustomBody *deuter );
|
||||
static Oyster::Physics::ICustomBody::SubscriptMessage PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj);
|
||||
static Oyster::Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj);
|
||||
|
||||
static Oyster::Physics::ICustomBody::SubscriptMessage LevelCollision(const Oyster::Physics::ICustomBody *rigidBodyLevel, const Oyster::Physics::ICustomBody *obj);
|
||||
//these are the specific collision case functions
|
||||
//void PlayerVBox(Player &player, DynamicObject &box);
|
||||
//void BoxVBox(DynamicObject &box1, DynamicObject &box2);
|
||||
|
|
|
@ -55,7 +55,7 @@ struct Game::PrivateData
|
|||
}
|
||||
|
||||
DynamicArray<PlayerData*> players;
|
||||
SmartPointer<Level> level;
|
||||
SmartPointer<LevelData> level;
|
||||
Utility::WinTimer timer;
|
||||
|
||||
}myData;
|
||||
|
@ -88,6 +88,16 @@ Game::PlayerData* Game::CreatePlayer()
|
|||
return this->myData->players[id];
|
||||
}
|
||||
|
||||
Game::LevelData* Game::CreateLevel()
|
||||
{
|
||||
Level *newLevel = new Level();
|
||||
newLevel->InitiateLevel(1000);
|
||||
LevelData *newLdata = new LevelData();
|
||||
newLdata->level = newLevel;
|
||||
myData->level = newLdata;
|
||||
return myData->level;
|
||||
}
|
||||
|
||||
void Game::CreateTeam()
|
||||
{
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace GameLogic
|
|||
* @param playerID: ID of the player you want to recieve the message
|
||||
* @param Usage: enum value on what kind of action is to be taken
|
||||
********************************************************/
|
||||
void UseWeapon(int playerID, const WEAPON_FIRE &Usage);
|
||||
void UseWeapon(int playerID, const WEAPON_FIRE &usage);
|
||||
|
||||
/********************************************************
|
||||
* Gets players position
|
||||
|
@ -65,6 +65,19 @@ namespace GameLogic
|
|||
int GetTeamID() const;
|
||||
};
|
||||
|
||||
struct DANBIAS_GAMELOGIC_DLL LevelData
|
||||
{
|
||||
private:
|
||||
friend class Game;
|
||||
Level *level;
|
||||
LevelData();
|
||||
~LevelData();
|
||||
|
||||
public:
|
||||
|
||||
|
||||
};
|
||||
|
||||
public:
|
||||
Game(void);
|
||||
~Game(void);
|
||||
|
@ -75,10 +88,15 @@ namespace GameLogic
|
|||
void GetAllPlayerPositions() const;
|
||||
|
||||
/********************************************************
|
||||
* Creates a player and returns PlayerData containing ID of the player
|
||||
* Creates a player and returns PlayerData
|
||||
********************************************************/
|
||||
PlayerData* CreatePlayer();
|
||||
|
||||
/********************************************************
|
||||
* Creates a level and returns LevelData
|
||||
********************************************************/
|
||||
LevelData* CreateLevel();
|
||||
|
||||
/********************************************************
|
||||
* Creates a team
|
||||
********************************************************/
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#include "Game.h"
|
||||
#include "Level.h"
|
||||
|
||||
using namespace GameLogic;
|
||||
|
||||
Game::LevelData::LevelData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Game::LevelData::~LevelData()
|
||||
{
|
||||
|
||||
}
|
|
@ -20,7 +20,7 @@ void Game::PlayerData::Move(const PLAYER_MOVEMENT &movement)
|
|||
{
|
||||
this->player->Move(movement);
|
||||
}
|
||||
void Game::PlayerData::UseWeapon(int playerID, const WEAPON_FIRE &Usage)
|
||||
void Game::PlayerData::UseWeapon(int playerID, const WEAPON_FIRE &usage)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace GameLogic
|
|||
IAttatchment(void);
|
||||
~IAttatchment(void);
|
||||
|
||||
virtual void UseAttatchment(const WEAPON_FIRE &fireInput) = 0;
|
||||
virtual void UseAttatchment(const WEAPON_FIRE &usage) = 0;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
using namespace GameLogic;
|
||||
using namespace Utility::DynamicMemory;
|
||||
|
||||
using namespace Oyster::Physics;
|
||||
|
||||
struct Level::PrivateData
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ struct Level::PrivateData
|
|||
|
||||
SmartPointer<GameMode> gameMode;
|
||||
|
||||
SmartPointer<Oyster::Physics::ICustomBody> rigidBodyLevel;
|
||||
SmartPointer<ICustomBody> rigidBodyLevel;
|
||||
|
||||
}myData;
|
||||
|
||||
|
@ -47,6 +47,27 @@ Level::~Level(void)
|
|||
void Level::InitiateLevel(std::string levelPath)
|
||||
{
|
||||
|
||||
}
|
||||
void Level::InitiateLevel(float radius)
|
||||
{
|
||||
API::SphericalBodyDescription sbDesc;
|
||||
sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,1);
|
||||
sbDesc.ignoreGravity = true;
|
||||
sbDesc.radius = radius;
|
||||
sbDesc.mass = 1e16; //10^16
|
||||
sbDesc.subscription = CollisionManager::LevelCollision;
|
||||
|
||||
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
|
||||
API::Instance().AddObject(rigidBody);
|
||||
|
||||
API::Gravity gravityWell;
|
||||
|
||||
gravityWell.gravityType = API::Gravity::GravityType_Well;
|
||||
gravityWell.well.mass = (float)1e16;
|
||||
gravityWell.well.position = Oyster::Math::Float4(0,0,0,1);
|
||||
|
||||
API::Instance().AddGravity(gravityWell);
|
||||
|
||||
}
|
||||
|
||||
void Level::AddPlayerToTeam(Player *player, int teamID)
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace GameLogic
|
|||
* @param levelPath: Path to a file that contains all information on the level
|
||||
********************************************************/
|
||||
void InitiateLevel(std::string levelPath);
|
||||
void Level::InitiateLevel(float radius);
|
||||
|
||||
/********************************************************
|
||||
* Creates a team in the level
|
||||
|
|
|
@ -79,9 +79,9 @@ void Player::MoveLeft()
|
|||
setState.ApplyLinearImpulse(-r * 100);
|
||||
}
|
||||
|
||||
void Player::UseWeapon(const WEAPON_FIRE &Usage)
|
||||
void Player::UseWeapon(const WEAPON_FIRE &usage)
|
||||
{
|
||||
this->weapon->Use(Usage);
|
||||
this->weapon->Use(usage);
|
||||
}
|
||||
|
||||
void Player::Respawn(Oyster::Math::Float3 spawnPoint)
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace GameLogic
|
|||
* Uses the weapon based on input
|
||||
* @param fireInput: enum value on what kind of action is to be taken
|
||||
********************************************************/
|
||||
void UseWeapon(const WEAPON_FIRE &Usage);
|
||||
void UseWeapon(const WEAPON_FIRE &usage);
|
||||
|
||||
/********************************************************
|
||||
* Respawns the player, this resets several stats and settings on the player
|
||||
|
|
|
@ -50,11 +50,11 @@ Weapon::~Weapon(void)
|
|||
/********************************************************
|
||||
* Uses the weapon based on the input given and the current chosen attatchment
|
||||
********************************************************/
|
||||
void Weapon::Use(const WEAPON_FIRE &fireInput)
|
||||
void Weapon::Use(const WEAPON_FIRE &usage)
|
||||
{
|
||||
if (myData->selectedAttatchment)
|
||||
{
|
||||
myData->selectedAttatchment->UseAttatchment(fireInput);
|
||||
myData->selectedAttatchment->UseAttatchment(usage);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "SimpleRigidBody.h"
|
||||
#include "SphericalRigidBody.h"
|
||||
|
||||
using namespace ::Oyster;
|
||||
using namespace ::Oyster::Physics;
|
||||
using namespace ::Oyster::Math;
|
||||
using namespace ::Oyster::Collision3D;
|
||||
|
@ -113,6 +114,7 @@ API_Impl::API_Impl()
|
|||
this->gravityConstant = Constant::gravity_constant;
|
||||
this->updateFrameLength = 1.0f / 120.0f;
|
||||
this->destructionAction = Default::EventAction_Destruction;
|
||||
this->gravity = ::std::vector<Gravity>();
|
||||
this->worldScene = Octree();
|
||||
}
|
||||
|
||||
|
@ -121,6 +123,8 @@ API_Impl::~API_Impl() {}
|
|||
void API_Impl::Init( unsigned int numObjects, unsigned int numGravityWells , const Float3 &worldSize )
|
||||
{
|
||||
unsigned char numLayers = 4; //!< @todo TODO: calc numLayers from worldSize
|
||||
this->gravity.resize( 0 );
|
||||
this->gravity.reserve( numGravityWells );
|
||||
this->worldScene = Octree( numObjects, numLayers, worldSize );
|
||||
}
|
||||
|
||||
|
@ -153,14 +157,39 @@ float API_Impl::GetFrameTimeLength() const
|
|||
|
||||
void API_Impl::Update()
|
||||
{ /** @todo TODO: Update is a temporary solution .*/
|
||||
|
||||
|
||||
|
||||
::std::vector<ICustomBody*> updateList;
|
||||
ICustomBody::State state;
|
||||
auto proto = this->worldScene.Sample( Universe(), updateList ).begin();
|
||||
for( ; proto != updateList.end(); ++proto )
|
||||
{
|
||||
// Step 1: @todo TODO: Apply Gravity
|
||||
// Step 1: Apply Gravity
|
||||
(*proto)->GetState( state );
|
||||
for( ::std::vector<Gravity>::size_type i = 0; i < this->gravity.size(); ++i )
|
||||
{
|
||||
switch( this->gravity[i].gravityType )
|
||||
{
|
||||
case Gravity::GravityType_Well:
|
||||
{
|
||||
Float4 d = state.GetCenterPosition() - Float4( this->gravity[i].well.position, 1.0f );
|
||||
Float rSquared = d.Dot( d );
|
||||
if( rSquared != 0.0 )
|
||||
{
|
||||
Float force = Physics3D::Formula::ForceField( this->gravityConstant, state.GetMass(), this->gravity[i].well.mass, rSquared );
|
||||
state.ApplyLinearImpulse( (this->updateFrameLength * force / ::std::sqrt(rSquared)) * d );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Gravity::GravityType_Directed:
|
||||
state.ApplyLinearImpulse( Float4(this->gravity[i].directed.impulse, 0.0f) );
|
||||
break;
|
||||
// case Gravity::GravityType_DirectedField:
|
||||
// //this->gravity[i].directedField.
|
||||
// //! TODO: @todo rethink
|
||||
// break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
(*proto)->SetState( state );
|
||||
|
||||
// Step 2: Apply Collision Response
|
||||
this->worldScene.Visit( *proto, OnPossibleCollision );
|
||||
|
@ -213,6 +242,24 @@ void API_Impl::DestroyObject( const ICustomBody* objRef )
|
|||
}
|
||||
}
|
||||
|
||||
void API_Impl::AddGravity( const API::Gravity &g )
|
||||
{
|
||||
this->gravity.push_back( g );
|
||||
}
|
||||
|
||||
void API_Impl::RemoveGravity( const API::Gravity &g )
|
||||
{
|
||||
for( ::std::vector<Gravity>::size_type i = this->gravity.size() - 1; i >= 0; --i )
|
||||
{
|
||||
if( g == this->gravity[i] )
|
||||
{
|
||||
int end = this->gravity.size() - 1;
|
||||
this->gravity[i] = this->gravity[end];
|
||||
this->gravity.resize( end );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//void API_Impl::ApplyForceAt( const ICustomBody* objRef, const Float3 &worldPos, const Float3 &worldF )
|
||||
//{
|
||||
// unsigned int tempRef = this->worldScene.GetTemporaryReferenceOf( objRef );
|
||||
|
|
|
@ -32,6 +32,9 @@ namespace Oyster
|
|||
::Utility::DynamicMemory::UniquePointer<ICustomBody> ExtractObject( const ICustomBody* objRef );
|
||||
void DestroyObject( const ICustomBody* objRef );
|
||||
|
||||
void AddGravity( const Gravity &g );
|
||||
void RemoveGravity( const Gravity &g );
|
||||
|
||||
//void ApplyForceAt( const ICustomBody* objRef, const ::Oyster::Math::Float3 &worldPos, const ::Oyster::Math::Float3 &worldF );
|
||||
|
||||
//void SetMomentOfInertiaTensor_KeepVelocity( const ICustomBody* objRef, const ::Oyster::Math::Float4x4 &localI );
|
||||
|
@ -49,6 +52,7 @@ namespace Oyster
|
|||
private:
|
||||
::Oyster::Math::Float gravityConstant, updateFrameLength;
|
||||
EventAction_Destruction destructionAction;
|
||||
::std::vector<Gravity> gravity;
|
||||
Octree worldScene;
|
||||
};
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace Oyster
|
|||
struct SimpleBodyDescription;
|
||||
struct SphericalBodyDescription;
|
||||
struct CustomBodyState;
|
||||
struct Gravity;
|
||||
}
|
||||
|
||||
enum UpdateState
|
||||
|
@ -40,6 +41,7 @@ namespace Oyster
|
|||
public:
|
||||
typedef Struct::SimpleBodyDescription SimpleBodyDescription;
|
||||
typedef Struct::SphericalBodyDescription SphericalBodyDescription;
|
||||
typedef Struct::Gravity Gravity;
|
||||
|
||||
typedef void (*EventAction_Destruction)( ::Utility::DynamicMemory::UniquePointer<ICustomBody> proto );
|
||||
|
||||
|
@ -124,6 +126,16 @@ namespace Oyster
|
|||
********************************************************/
|
||||
virtual void DestroyObject( const ICustomBody* objRef ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* TODO: @todo doc
|
||||
********************************************************/
|
||||
virtual void AddGravity( const Gravity &g ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* TODO: @todo doc
|
||||
********************************************************/
|
||||
virtual void RemoveGravity( const Gravity &g ) = 0;
|
||||
|
||||
///********************************************************
|
||||
// * Apply force on an object.
|
||||
// * @param objRef: A pointer to the ICustomBody representing a physical object.
|
||||
|
|
|
@ -353,6 +353,26 @@ namespace Oyster
|
|||
return *this;
|
||||
}
|
||||
|
||||
inline bool GravityWell::operator == ( const GravityWell &gravity ) const
|
||||
{
|
||||
if( this->position == gravity.position )
|
||||
if( this->mass == gravity.mass )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool GravityWell::operator != ( const GravityWell &gravity ) const
|
||||
{
|
||||
if( this->position == gravity.position )
|
||||
if( this->mass == gravity.mass )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
inline GravityDirected::GravityDirected( )
|
||||
{
|
||||
this->impulse = ::Oyster::Math::Float3::null;
|
||||
|
@ -370,6 +390,16 @@ namespace Oyster
|
|||
return *this;
|
||||
}
|
||||
|
||||
inline bool GravityDirected::operator == ( const GravityDirected &gravity ) const
|
||||
{
|
||||
return this->impulse == gravity.impulse;
|
||||
}
|
||||
|
||||
inline bool GravityDirected::operator != ( const GravityDirected &gravity ) const
|
||||
{
|
||||
return this->impulse != gravity.impulse;
|
||||
}
|
||||
|
||||
inline GravityDirectedField::GravityDirectedField( )
|
||||
{
|
||||
this->normalizedDirection = ::Oyster::Math::Float3::null;
|
||||
|
@ -393,6 +423,28 @@ namespace Oyster
|
|||
return *this;
|
||||
}
|
||||
|
||||
inline bool GravityDirectedField::operator == ( const GravityDirectedField &gravity ) const
|
||||
{
|
||||
if( this->normalizedDirection == gravity.normalizedDirection )
|
||||
if( this->mass == gravity.mass )
|
||||
if( this->magnitude == gravity.magnitude )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool GravityDirectedField::operator != ( const GravityDirectedField &gravity ) const
|
||||
{
|
||||
if( this->normalizedDirection == gravity.normalizedDirection )
|
||||
if( this->mass == gravity.mass )
|
||||
if( this->magnitude == gravity.magnitude )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
inline Gravity::Gravity()
|
||||
{
|
||||
this->gravityType = GravityType_Undefined;
|
||||
|
@ -437,6 +489,36 @@ namespace Oyster
|
|||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool Gravity::operator == ( const Gravity &gravity ) const
|
||||
{
|
||||
if( this->gravityType == gravity.gravityType )
|
||||
{
|
||||
switch( this->gravityType )
|
||||
{
|
||||
case GravityType_Well: return this->well == gravity.well;
|
||||
case GravityType_Directed: return this->directed == gravity.directed;
|
||||
case GravityType_DirectedField: return this->directedField == gravity.directedField;
|
||||
default: return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool Gravity::operator != ( const Gravity &gravity ) const
|
||||
{
|
||||
if( this->gravityType == gravity.gravityType )
|
||||
{
|
||||
switch( this->gravityType )
|
||||
{
|
||||
case GravityType_Well: return this->well != gravity.well;
|
||||
case GravityType_Directed: return this->directed != gravity.directed;
|
||||
case GravityType_DirectedField: return this->directedField != gravity.directedField;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,10 @@ namespace Oyster { namespace Physics
|
|||
|
||||
GravityWell( );
|
||||
GravityWell( const GravityWell &gravityWell );
|
||||
GravityWell& operator=( const GravityWell &gravityWell );
|
||||
GravityWell & operator = ( const GravityWell &gravityWell );
|
||||
|
||||
bool operator == ( const GravityWell &gravity ) const;
|
||||
bool operator != ( const GravityWell &gravity ) const;
|
||||
};
|
||||
|
||||
struct GravityDirected
|
||||
|
@ -133,6 +136,9 @@ namespace Oyster { namespace Physics
|
|||
GravityDirected( );
|
||||
GravityDirected( const GravityDirected &gravityDirected );
|
||||
GravityDirected & operator = ( const GravityDirected &gravityDirected );
|
||||
|
||||
bool operator == ( const GravityDirected &gravity ) const;
|
||||
bool operator != ( const GravityDirected &gravity ) const;
|
||||
};
|
||||
|
||||
struct GravityDirectedField
|
||||
|
@ -143,7 +149,10 @@ namespace Oyster { namespace Physics
|
|||
|
||||
GravityDirectedField( );
|
||||
GravityDirectedField( const GravityDirectedField &gravityDirectedField );
|
||||
GravityDirectedField & operator=( const GravityDirectedField &gravityDirectedField );
|
||||
GravityDirectedField & operator = ( const GravityDirectedField &gravityDirectedField );
|
||||
|
||||
bool operator == ( const GravityDirectedField &gravity ) const;
|
||||
bool operator != ( const GravityDirectedField &gravity ) const;
|
||||
};
|
||||
|
||||
struct Gravity
|
||||
|
@ -177,6 +186,9 @@ namespace Oyster { namespace Physics
|
|||
Gravity( );
|
||||
Gravity( const Gravity &gravity );
|
||||
Gravity & operator = ( const Gravity &gravity );
|
||||
|
||||
bool operator == ( const Gravity &gravity ) const;
|
||||
bool operator != ( const Gravity &gravity ) const;
|
||||
};
|
||||
}
|
||||
} }
|
||||
|
|
|
@ -204,7 +204,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
|||
return true;
|
||||
}
|
||||
|
||||
bool SeperatingAxisTest_AxisAlignedVsTransformedBox( const Float4 &boundingOffsetA, const Float4 &boundingOffsetB, const Float4x4 &rotationB, const Float4 &worldOffset, Float4 &worldPointOfContact )
|
||||
bool SeperatingAxisTest_AxisAlignedVsTransformedBox( const Float4 &boundingOffsetA, const Float4 &boundingOffsetB, const Float4x4 &rotationB, const Float4 &worldOffset, Float4 &localPointOfContact )
|
||||
{ // by Dan Andersson
|
||||
|
||||
/*****************************************************************
|
||||
|
@ -241,7 +241,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
|||
{ // no intersection
|
||||
return false;
|
||||
}
|
||||
worldPointOfContact = s * ( centerSeperation * eA / edgeSeperation );
|
||||
localPointOfContact = s * ( centerSeperation * eA / edgeSeperation );
|
||||
|
||||
s = Float4::standard_unit_y;
|
||||
centerSeperation = t.Dot(s);
|
||||
|
@ -251,7 +251,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
|||
{ // no intersection
|
||||
return false;
|
||||
}
|
||||
worldPointOfContact += s * ( centerSeperation * eA / edgeSeperation );
|
||||
localPointOfContact += s * ( centerSeperation * eA / edgeSeperation );
|
||||
|
||||
s = Float4::standard_unit_z;
|
||||
centerSeperation = t.Dot(s);
|
||||
|
@ -261,7 +261,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
|||
{ // no intersection
|
||||
return false;
|
||||
}
|
||||
worldPointOfContact += s * ( centerSeperation * eA / edgeSeperation );
|
||||
localPointOfContact += s * ( centerSeperation * eA / edgeSeperation );
|
||||
|
||||
s = rotationB.v[0];
|
||||
centerSeperation = t.Dot(s);
|
||||
|
@ -271,7 +271,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
|||
{ // no intersection
|
||||
return false;
|
||||
}
|
||||
worldPointOfContact += s * ( centerSeperation * eA / edgeSeperation );
|
||||
localPointOfContact += s * ( centerSeperation * eA / edgeSeperation );
|
||||
|
||||
s = rotationB.v[1];
|
||||
centerSeperation = t.Dot(s);
|
||||
|
@ -281,7 +281,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
|||
{ // no intersection
|
||||
return false;
|
||||
}
|
||||
worldPointOfContact += s * ( centerSeperation * eA / edgeSeperation );
|
||||
localPointOfContact += s * ( centerSeperation * eA / edgeSeperation );
|
||||
|
||||
s = rotationB.v[2];
|
||||
centerSeperation = t.Dot(s);
|
||||
|
@ -291,7 +291,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
|||
{ // no intersection
|
||||
return false;
|
||||
}
|
||||
worldPointOfContact += s * ( centerSeperation * eA / edgeSeperation ); // enough point of contact data gathered for approximative result.
|
||||
localPointOfContact += s * ( centerSeperation * eA / edgeSeperation ); // enough point of contact data gathered for approximative result.
|
||||
|
||||
s = Float4( Float3::standard_unit_x.Cross(rotationB.v[0].xyz), 0.0f );
|
||||
centerSeperation = t.Dot(s);
|
||||
|
@ -374,7 +374,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
|||
return false;
|
||||
}
|
||||
|
||||
worldPointOfContact *= 0.5f;
|
||||
localPointOfContact *= 0.5f;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -821,10 +821,11 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
|||
Float4 alignedOffsetBoundaries = (boxB.maxVertex - boxB.minVertex) * 0.5f,
|
||||
offset = boxA.center - Average( boxB.maxVertex, boxB.minVertex );
|
||||
|
||||
Float4 pointOfContact;
|
||||
if( Private::SeperatingAxisTest_AxisAlignedVsTransformedBox( alignedOffsetBoundaries, boxA.boundingOffset, boxA.rotation, offset, pointOfContact ) )
|
||||
Float4 localPointOfContact;
|
||||
if( Private::SeperatingAxisTest_AxisAlignedVsTransformedBox( alignedOffsetBoundaries, boxA.boundingOffset, boxA.rotation, offset, localPointOfContact ) )
|
||||
{
|
||||
worldPointOfContact = pointOfContact.xyz;
|
||||
worldPointOfContact = localPointOfContact + boxA.center;
|
||||
worldPointOfContact.w = 1.0f;
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
|
@ -843,10 +844,12 @@ namespace Oyster { namespace Collision3D { namespace Utility
|
|||
Float4x4 rotationB = TransformMatrix( InverseRotationMatrix(boxA.rotation), boxB.rotation );
|
||||
Float4 posB = boxB.center - boxA.center;
|
||||
|
||||
Float4 pointOfContact;
|
||||
if( Private::SeperatingAxisTest_AxisAlignedVsTransformedBox( boxA.boundingOffset, boxB.boundingOffset, rotationB, posB, pointOfContact ) )
|
||||
Float4 localPointOfContact;
|
||||
if( Private::SeperatingAxisTest_AxisAlignedVsTransformedBox( boxA.boundingOffset, boxB.boundingOffset, rotationB, posB, localPointOfContact ) )
|
||||
{
|
||||
worldPointOfContact = TransformVector( boxA.rotation, pointOfContact, pointOfContact ).xyz;
|
||||
worldPointOfContact = TransformVector( boxA.rotation, localPointOfContact, localPointOfContact );
|
||||
worldPointOfContact += boxA.center;
|
||||
worldPointOfContact.w = 1.0f;
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
|
|
|
@ -273,6 +273,22 @@ namespace Oyster { namespace Physics3D
|
|||
return momentOfInertia * angularImpulseAcceleration;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* @todo TODO: doc
|
||||
******************************************************************/
|
||||
inline ::Oyster::Math::Float ForceField( ::Oyster::Math::Float g, ::Oyster::Math::Float massA, ::Oyster::Math::Float massB, ::Oyster::Math::Float radiusSquared )
|
||||
{
|
||||
return g * massA * massB / radiusSquared;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* @todo TODO: doc
|
||||
******************************************************************/
|
||||
inline ::Oyster::Math::Float ForceField( ::Oyster::Math::Float g, ::Oyster::Math::Float massA, ::Oyster::Math::Float massB, const ::Oyster::Math::Float4 &deltaPos )
|
||||
{
|
||||
return g * massA * massB / deltaPos.Dot( deltaPos );
|
||||
}
|
||||
|
||||
namespace MomentOfInertia
|
||||
{ /// Library of Formulas to calculate moment of inerta for simple shapes
|
||||
/** @todo TODO: add MomentOfInertia tensor formulas */
|
||||
|
|
Loading…
Reference in New Issue