Gameserver - Merge with gamelogic

This commit is contained in:
Dennis Andersen 2014-01-31 22:36:43 +01:00
commit 5aede62af6
28 changed files with 198 additions and 69 deletions

View File

@ -38,7 +38,7 @@ namespace DanBias
public:
WindowShell* window;
InputClass* inputObj;
Utility::WinTimer* timer;
Utility::WinTimer timer;
GameRecieverObject* recieverObj;
bool serverOwner;
@ -73,8 +73,7 @@ namespace DanBias
if(!m_data->recieverObj->gameClientState->Init(m_data->recieverObj))
return DanBiasClientReturn_Error;
m_data->timer = new Utility::WinTimer(); //why dynamic memory?
m_data->timer->reset();
m_data->timer.reset();
return DanBiasClientReturn_Sucess;
}
@ -83,8 +82,8 @@ namespace DanBias
// Main message loop
while(m_data->window->Frame())
{
float dt = (float)m_data->timer->getElapsedSeconds();
m_data->timer->reset();
float dt = (float)m_data->timer.getElapsedSeconds();
m_data->timer.reset();
capFrame += dt;
if(capFrame > 0.03)
@ -131,8 +130,9 @@ namespace DanBias
HRESULT DanBiasGame::Update(float deltaTime)
{
if(m_data->recieverObj->IsConnected())
m_data->recieverObj->Update();
m_data->inputObj->Update();
if(m_data->serverOwner)
@ -157,7 +157,13 @@ namespace DanBias
m_data->recieverObj->gameClientState = new Client::LobbyState();
break;
case Client::GameClientState::ClientState_Game:
if(m_data->serverOwner)
DanBias::GameServerAPI::GameStart();
m_data->recieverObj->gameClientState = new Client::GameState();
if(m_data->serverOwner)
((Client::GameState*)m_data->recieverObj->gameClientState)->setClientId(2);
else
((Client::GameState*)m_data->recieverObj->gameClientState)->setClientId(3);
break;
default:
return E_FAIL;
@ -192,7 +198,6 @@ namespace DanBias
delete m_data->recieverObj->gameClientState;
m_data->recieverObj->Disconnect();
delete m_data->recieverObj;
delete m_data->timer;
delete m_data->inputObj;
delete m_data;

View File

@ -2,6 +2,8 @@
#define DANBIAS_CLIENTRECIEVEROBJECT_H
//WTF!? No headers included???
#include "../DanBiasGame/Include/DanBiasGame.h"
#include "../GameProtocols/GeneralProtocols.h"
namespace DanBias
{
@ -100,6 +102,18 @@ namespace DanBias
((Client::GameState*)gameClientState)->Protocol(&protocolData);
}
break;
case protocol_Lobby_Start:
{
/*
if(dynamic_cast<Client::LobbyState*>(gameClientState))
{
gameClientState->Release();
delete gameClientState;
gameClientState = new Client::GameState();
gameClientState->Init(m_data->recieverObj);
}*/
}
break;
default:
break;
@ -128,8 +142,8 @@ namespace DanBias
break;
case protocol_Lobby_GameData: //this->LobbyGameData (Protocol_LobbyGameData (p), c);
{
GameLogic::Protocol_LobbyGameData temp(p);
printf("%s, %i.%i\n", temp.mapName.c_str(), temp.majorVersion, temp.minorVersion);
//GameLogic::Protocol_LobbyGameData temp(p);
//printf("%s, %i.%i\n", temp.mapName.c_str(), temp.majorVersion, temp.minorVersion);
}
break;
case protocol_Lobby_ClientData: //this->LobbyMainData (Protocol_LobbyClientData (p), c);

View File

@ -53,6 +53,7 @@ public:
{
ClientState_Login,
ClientState_Lobby,
ClientState_Lan,
ClientState_LobbyCreated,
ClientState_Game,
ClientState_Same,

View File

@ -114,6 +114,18 @@ bool GameState::LoadModels(std::wstring mapFile)
privData->object.push_back(obj);
privData->object[privData->object.size() -1 ]->Init(modelData);
// add player model 2
modelData.world = Oyster::Math3D::Float4x4::identity;
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(10, 320, 0));
modelData.world = modelData.world * translate;
modelData.visible = true;
modelData.modelPath = L"..\\Content\\Models\\char_white.dan";
modelData.id = 3;
// load models
obj = new C_Player();
privData->object.push_back(obj);
privData->object[privData->object.size() -1 ]->Init(modelData);
return true;
@ -137,7 +149,10 @@ bool GameState::InitCamera(Oyster::Math::Float3 startPos)
privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
return true;
}
void GameState::setClientId(int id)
{
myId = id;
}
GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyInput)
{
switch (privData->state)
@ -344,7 +359,7 @@ void GameState::Protocol( ObjPos* pos )
//camera->setRight((Oyster::Math::Float3(world[0], world[1], world[2])));
//camera->setUp((Oyster::Math::Float3(world[4], world[5], world[6])));
//camera->setLook((Oyster::Math::Float3(world[8], world[9], world[10])));
if(i == 2) // playerobj
if(i == myId) // playerobj
{
camera->SetPosition(Oyster::Math::Float3(world[12], world[13]+2.2f, world[14]-1));
camera->UpdateViewMatrix();

View File

@ -26,6 +26,7 @@ private:
bool key_Jump;
Camera* camera;
int myId;
struct myData;
myData* privData;
public:
@ -36,7 +37,7 @@ public:
bool LoadModels(std::wstring mapFile) ;
bool InitCamera(Oyster::Math::Float3 startPos) ;
gameStateState LoadGame();
void setClientId(int id);
void readKeyInput(InputClass* KeyInput);
bool Render()override;
bool Release()override;

View File

@ -5,6 +5,10 @@
#include "C_obj/C_DynamicObj.h"
#include "DllInterfaces/GFXAPI.h"
#include "LobbyState.h"
#include "GameState.h"
#include "../GameClientRecieverFunc.h"
#include <GameServerAPI.h>
using namespace DanBias::Client;
@ -16,6 +20,10 @@ struct LanMenuState::myData
Oyster::Math3D::Float4x4 proj;
C_Object* object[2];
int modelCount;
GameRecieverObject* recieverObj;
bool serverOwner;
// UI object
// game client*
}privData;
@ -83,6 +91,49 @@ bool LanMenuState::InitCamera(Oyster::Math::Float3 startPos)
}
GameClientState::ClientState LanMenuState::Update(float deltaTime, InputClass* KeyInput)
{
/*ChangeState(KeyInput);
if(privData->recieverObj->IsConnected())
privData->recieverObj->Update();
KeyInput->Update();
if(privData->serverOwner)
{
DanBias::GameServerAPI::ServerUpdate();
}
DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same;
state = privData->recieverObj->gameClientState->Update(deltaTime, KeyInput);
if(state != Client::GameClientState::ClientState_Same)
{
privData->recieverObj->gameClientState->Release();
delete privData->recieverObj->gameClientState;
privData->recieverObj->gameClientState = NULL;
switch (state)
{
case Client::GameClientState::ClientState_LobbyCreated:
privData->serverOwner = true;
case Client::GameClientState::ClientState_Lobby:
privData->recieverObj->gameClientState = new Client::LobbyState();
break;
case Client::GameClientState::ClientState_Game:
privData->recieverObj->gameClientState = new Client::GameState();
break;
default:
//return E_FAIL;
break;
}
privData->recieverObj->gameClientState->Init(privData->recieverObj); // send game client
}*/
return ChangeState(KeyInput);
}
GameClientState::ClientState LanMenuState::ChangeState(InputClass* KeyInput)
{
// create game
if( KeyInput->IsKeyPressed(DIK_C))

View File

@ -17,6 +17,8 @@ namespace DanBias
virtual bool Init(Oyster::Network::NetworkClient* nwClient);
virtual ClientState Update(float deltaTime, InputClass* KeyInput);
ClientState ChangeState(InputClass* KeyInput);
bool LoadModels(std::wstring file);
bool InitCamera(Oyster::Math::Float3 startPos);

View File

@ -88,11 +88,8 @@ GameClientState::ClientState LobbyState::Update(float deltaTime, InputClass* Key
// send data to server
// check data from server
if( KeyInput->IsKeyPressed(DIK_G))
{
if(!DanBias::GameServerAPI::GameStart())
return GameClientState::ClientState_Same;
return ClientState_Game;
}

View File

@ -36,6 +36,7 @@ public:
bool Release();
void Protocol(ProtocolStruct* protocol)override;
void PlayerJoinProtocol(PlayerName* name);
void GameStarted();
};};};
#endif // ! DANBIAS_CLIENT_GAMECLIENTSTATE_H

View File

@ -109,7 +109,7 @@ GameClientState::ClientState LoginState::Update(float deltaTime, InputClass* Key
if( KeyInput->IsKeyPressed(DIK_J))
{
// game ip
nwClient->Connect(15151, "194.47.150.56");
nwClient->Connect(15151, "127.0.0.1");
if (!nwClient->IsConnected())
{

View File

@ -1,5 +1,6 @@
#include "AttatchmentMassDriver.h"
#include "PhysicsAPI.h"
#include "GameLogicStates.h"
using namespace GameLogic;
@ -45,17 +46,16 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
********************************************************/
void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float dt)
{
//Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt);
Oyster::Math::Float3 look = owner->GetLookDir();
Oyster::Math::Float3 up = -owner->GetRigidBody()->GetGravityNormal();
Oyster::Math::Float3 pos = owner->GetPosition();
Oyster::Math::Float4x4 aim = Oyster::Math3D::OrientationMatrix_LookAtDirection(owner->GetLookDir(), -owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition());
Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt);
Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition());
Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20);
Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace));
int arg = 0;
forcePushData args;
args.pushForce = pushForce;
Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,&arg,ForcePushAction);
Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,&args,ForcePushAction);
}
/********************************************************

View File

@ -84,20 +84,13 @@ using namespace GameLogic;
void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj, void *args)
{
Oyster::Math::Float3 pushForce = Oyster::Math::Float4(1,0,0) * (500);
Oyster::Physics::ICustomBody::State state;
Object *realObj = (Object*)obj->GetCustomTag();
if(realObj->GetObjectType() == OBJECT_TYPE_BOX)
{
state = obj->GetState();
state.SetOrientation(Oyster::Math::Float3(1,0.5,1),Oyster::Math::Float3(1,0.5,1));
obj->SetState(state);
}
if(realObj->GetObjectType() == OBJECT_TYPE_PLAYER || realObj->GetObjectType() == OBJECT_TYPE_WORLD)
return;
state = obj->GetState();
state.ApplyLinearImpulse(pushForce);
state.ApplyLinearImpulse(((forcePushData*)(args))->pushForce);
obj->SetState(state);
//((Object*)obj->GetCustomTag())->ApplyLinearImpulse(pushForce);
}

View File

@ -1,5 +1,6 @@
#ifndef GAMELOGICSTATES_H
#define GAMELOGICSTATES_H
#include "OysterMath.h"
namespace GameLogic
{
@ -46,6 +47,12 @@ namespace GameLogic
WEAPON_STATE_RELOADING = 2,
};
struct forcePushData
{
Oyster::Math::Float3 pushForce;
};
};

View File

@ -7,9 +7,10 @@ Game::PlayerData::PlayerData()
{
//set some stats that are appropriate to a player
Oyster::Physics::API::SimpleBodyDescription sbDesc;
sbDesc.centerPosition = Oyster::Math::Float3(10,350,0);
sbDesc.centerPosition = Oyster::Math::Float3(0,308,0);
sbDesc.size = Oyster::Math::Float3(4,7,4);
sbDesc.mass = 70;
sbDesc.restitutionCoeff = 0.5;
//create rigid body
Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release();

View File

@ -32,7 +32,7 @@ void Level::InitiateLevel(float radius)
ICustomBody::State state;
rigidBody->GetState(state);
state.SetRestitutionCoeff(0.01);
state.SetRestitutionCoeff(0.2);
rigidBody->SetState(state);
levelObj = new StaticObject(rigidBody, LevelCollisionBefore, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD);
@ -41,10 +41,10 @@ void Level::InitiateLevel(float radius)
// add box
API::SimpleBodyDescription sbDesc_TestBox;
sbDesc_TestBox.centerPosition = Oyster::Math::Float4(0,320,0,0);
sbDesc_TestBox.centerPosition = Oyster::Math::Float4(10,320,0,0);
sbDesc_TestBox.ignoreGravity = false;
sbDesc_TestBox.mass = 50;
sbDesc_TestBox.size = Oyster::Math::Float4(1,1,1,0);
sbDesc_TestBox.size = Oyster::Math::Float4(4,4,4,0);
ICustomBody* rigidBody_TestBox = API::Instance().CreateRigidBody(sbDesc_TestBox).Release();
rigidBody_TestBox->SetSubscription(Level::PhysicsOnMoveLevel);

View File

@ -118,18 +118,22 @@ Oyster::Physics::ICustomBody* Object::GetRigidBody()
void Object::BeginFrame()
{
Oyster::Math::Float4 axis;
if(setState.GetGravityNormal()!= Float3::null)
{
Oyster::Math3D::SnapAngularAxis(Oyster::Math::Float4(setState.GetAngularAxis(), 0), Oyster::Math::Float4::standard_unit_y, -Oyster::Math::Float4(setState.GetGravityNormal()), axis);
setState.SetRotation(axis.xyz);
setState.SetAngularMomentum(Float3::null);
Oyster::Math::Float3 debug = ::LinearAlgebra3D::WorldAxisOf(::LinearAlgebra3D::Rotation(axis.xyz), Oyster::Math::Float3::standard_unit_y);
debug += setState.GetGravityNormal();
}
this->rigidBody->SetState(this->setState);
}
// update physic
void Object::EndFrame()
{
Oyster::Math::Float4x4 rotMatrix = setState.GetOrientation(); //Oyster::Math3D::RotationMatrix(rot, axis);
//Oyster::Math3D::SnapAxisYToNormal_UsingNlerp(rotMatrix, -setState.GetGravityNormal());
//setState.SetOrientation(rotMatrix);
this->getState = this->rigidBody->GetState();
this->setState = this->getState;
}

View File

@ -86,13 +86,15 @@ namespace DanBias
if(dynamic_cast<IPlayerData*> (movedObject))
{
IPlayerData* temp = (IPlayerData*)movedObject;
temp->GetID();
int id = temp->GetID();
Oyster::Math::Float4x4 world = temp->GetOrientation();
Protocol_ObjectPosition p(world, 2);
Protocol_ObjectPosition p(world, id);
GameSession::gameSession->Send(*p.GetProtocol());
}
else if(dynamic_cast<GameLogic::ILevelData*>(movedObject))
if(dynamic_cast<GameLogic::ILevelData*>(movedObject))
{
GameLogic::IObjectData* obj = NULL;
obj = ((GameLogic::ILevelData*)movedObject)->GetObjectAt(0);
@ -100,10 +102,10 @@ namespace DanBias
{
if(obj->GetObjectType() == OBJECT_TYPE_WORLD)
{
obj->GetID();
int id = obj->GetID();
Oyster::Math::Float4x4 world =obj->GetOrientation();
Protocol_ObjectPosition p(world, 0);
Protocol_ObjectPosition p(world, id);
GameSession::gameSession->Send(*p.GetProtocol());
}
}
@ -114,9 +116,9 @@ namespace DanBias
{
if(obj->GetObjectType() == OBJECT_TYPE_BOX)
{
obj->GetID();
int id = obj->GetID();
Oyster::Math::Float4x4 world = obj->GetOrientation();
Protocol_ObjectPosition p(world, 1);
Protocol_ObjectPosition p(world, id);
GameSession::gameSession->Send(*p.GetProtocol());
}
}

View File

@ -187,7 +187,7 @@ void API_Impl::Update()
if( gravityImpulse != Float4::null )
{
state.ApplyLinearImpulse( gravityImpulse.xyz );
(*proto)->SetGravityNormal( gravityImpulse.GetNormalized().xyz );
state.SetGravityNormal( gravityImpulse.GetNormalized().xyz );
(*proto)->SetState( state );
}
@ -198,24 +198,27 @@ void API_Impl::Update()
proto = updateList.begin();
for( ; proto != updateList.end(); ++proto )
{
Float3 lM = state.GetLinearMomentum() + state.GetLinearImpulse();
(*proto)->GetState( state );
Float3 lM = state.GetLinearMomentum();
if( lM.x < this->epsilon )
//LinearAlgebra3D::InterpolateAxisYToNormal_UsingNlerp(state.SetOrientation(, Float4(state.GetGravityNormal(), 0.0f), 1.0f);
if( abs(lM.x) < this->epsilon )
{
state.SetLinearMomentum( Float3(0, lM.y, lM.z) );
state.SetLinearImpulse( Float3(0, lM.y, lM.z) );
state.linearMomentum.x = 0;
}
if( lM.y < this->epsilon )
if( abs(lM.y) < this->epsilon )
{
state.SetLinearMomentum( Float3(lM.x, 0, lM.z) );
state.SetLinearImpulse( Float3(lM.x, 0, lM.z) );
state.linearMomentum.y = 0;
}
if( lM.z < this->epsilon )
if( abs(lM.z) < this->epsilon )
{
state.SetLinearMomentum( Float3(lM.x, lM.y, 0) );
state.SetLinearImpulse( Float3(lM.x, lM.y, 0) );
state.linearMomentum.z = 0;
}
(*proto)->SetState( state );
switch( (*proto)->Update(this->updateFrameLength) )
{
case UpdateState_altered:

View File

@ -128,7 +128,7 @@ SimpleRigidBody::State & SimpleRigidBody::GetState( SimpleRigidBody::State &targ
void SimpleRigidBody::SetState( const SimpleRigidBody::State &state )
{
this->rigid.centerPos = state.GetCenterPosition();
//this->rigid.SetRotation( state.GetRotation() ); //! HACK: @todo Rotation temporary disabled
this->rigid.axis = state.GetAngularAxis();
this->rigid.boundingReach = state.GetReach();
this->rigid.momentum_Linear = state.GetLinearMomentum();
this->rigid.momentum_Angular = state.GetAngularMomentum();

View File

@ -94,7 +94,7 @@ SphericalRigidBody::State & SphericalRigidBody::GetState( SphericalRigidBody::St
void SphericalRigidBody::SetState( const SphericalRigidBody::State &state )
{
this->rigid.centerPos = state.GetCenterPosition();
//this->rigid.SetRotation( state.GetRotation() ); //! HACK: @todo Rotation temporary disabled
this->rigid.axis = state.GetAngularAxis();
this->rigid.boundingReach = state.GetReach();
this->rigid.momentum_Linear = state.GetLinearMomentum();
this->rigid.momentum_Angular = state.GetAngularMomentum();
@ -105,6 +105,7 @@ void SphericalRigidBody::SetState( const SphericalRigidBody::State &state )
this->rigid.frictionCoeff_Kinetic = state.GetFrictionCoeff_Kinetic();
this->rigid.SetMass_KeepMomentum( state.GetMass() );
this->rigid.SetMomentOfInertia_KeepMomentum( state.GetMomentOfInertia() );
this->rigid.gravityNormal = state.GetGravityNormal();
if( state.IsForwarded() )
{

View File

@ -34,7 +34,7 @@ namespace Oyster
namespace Constant
{
const float gravity_constant = (const float)6.67284e-11; //!< The _big_G_! ( N(m/kg)^2 ) Used in real gravityforcefields.
const float epsilon = (const float)1.0e-7;
const float epsilon = (const float)1.0e-3;
}
class PHYSICS_DLL_USAGE API

View File

@ -124,7 +124,7 @@ namespace Oyster
inline const ::Oyster::Math::Float3 & CustomBodyState::GetAngularAxis() const
{
return ::Utility::Value::Radian(this->angularAxis);
return this->angularAxis;
}
inline ::Oyster::Math::Float4x4 CustomBodyState::GetRotation() const

View File

@ -115,11 +115,13 @@ namespace Oyster { namespace Physics
bool IsDisturbed() const;
bool IsForwarded() const;
::Oyster::Math::Float3 linearMomentum;
private:
::Oyster::Math::Float mass, restitutionCoeff, staticFrictionCoeff, kineticFrictionCoeff;
::Oyster::Physics3D::MomentOfInertia inertiaTensor;
::Oyster::Math::Float3 reach, centerPos, angularAxis;
::Oyster::Math::Float3 linearMomentum, angularMomentum;
::Oyster::Math::Float3 angularMomentum;
::Oyster::Math::Float3 linearImpulse, angularImpulse;
::Oyster::Math::Float3 deltaPos, deltaAxis; // Forwarding data sum
::Oyster::Math::Float3 gravityNormal;

View File

@ -325,6 +325,12 @@ namespace LinearAlgebra2D
namespace LinearAlgebra3D
{
template<typename ScalarType>
inline ::LinearAlgebra::Vector3<ScalarType> WorldAxisOf( const ::LinearAlgebra::Quaternion<ScalarType> &rotation, const ::LinearAlgebra::Vector3<ScalarType> &localAxis )
{
return (rotation*localAxis*rotation.GetConjugate()).imaginary;
}
// All Matrix to AngularAxis conversions here is incorrect
//template<typename ScalarType>
//inline ::LinearAlgebra::Vector4<ScalarType> AngularAxis( const ::LinearAlgebra::Matrix3x3<ScalarType> &rotationMatrix )
@ -741,6 +747,23 @@ namespace LinearAlgebra3D
inline ::LinearAlgebra::Vector4<ScalarType> NormalProjection( const ::LinearAlgebra::Vector4<ScalarType> &vector, const ::LinearAlgebra::Vector4<ScalarType> &normalizedAxis )
{ return normalizedAxis * ( vector.Dot(normalizedAxis) ); }
template<typename ScalarType>
::LinearAlgebra::Vector4<ScalarType> & SnapAngularAxis( ::LinearAlgebra::Vector4<ScalarType> &startAngularAxis, const ::LinearAlgebra::Vector4<ScalarType> &localStartNormal, const ::LinearAlgebra::Vector4<ScalarType> &worldEndNormal, ::LinearAlgebra::Vector4<ScalarType> &targetMem = ::LinearAlgebra::Vector4<ScalarType>() )
{
::LinearAlgebra::Vector4<ScalarType> worldStartNormal( WorldAxisOf(Rotation(startAngularAxis.xyz), localStartNormal.xyz), (ScalarType)0 );
targetMem = ::LinearAlgebra::Vector4<ScalarType>( worldStartNormal.xyz.Cross(worldEndNormal.xyz), (ScalarType)0);
targetMem *= (ScalarType)::std::acos( worldStartNormal.Dot(worldEndNormal) );
return targetMem += startAngularAxis;
}
template<typename ScalarType>
::LinearAlgebra::Vector3<ScalarType> & SnapAngularAxis( ::LinearAlgebra::Vector3<ScalarType> &startAngularAxis, const ::LinearAlgebra::Vector3<ScalarType> &localStartNormal, const ::LinearAlgebra::Vector3<ScalarType> &worldEndNormal, ::LinearAlgebra::Vector3<ScalarType> &targetMem = ::LinearAlgebra::Vector3<ScalarType>() )
{
return targetMem = SnapAngularAxis( ::LinearAlgebra::Vector4<ScalarType>(startAngularAxis, (ScalarType)0),
::LinearAlgebra::Vector4<ScalarType>(localStartNormal, (ScalarType)0),
::LinearAlgebra::Vector4<ScalarType>(worldEndNormal, (ScalarType)0) ).xyz;
}
template<typename ScalarType>
::LinearAlgebra::Matrix4x4<ScalarType> & SnapAxisYToNormal_UsingNlerp( ::LinearAlgebra::Matrix4x4<ScalarType> &rotation, const ::LinearAlgebra::Vector4<ScalarType> &normalizedAxis )
{

View File

@ -324,6 +324,7 @@ namespace Oyster { namespace Math3D //! Oyster's native math library specialized
using ::LinearAlgebra3D::InterpolateAxisYToNormal_UsingNlerp;
using ::LinearAlgebra3D::InterpolateOrientation_UsingNonRigidNlerp;
using ::LinearAlgebra3D::InterpolateOrientation_UsingSlerp;
using ::LinearAlgebra3D::SnapAngularAxis;
} }
#endif

View File

@ -784,7 +784,7 @@ namespace Oyster { namespace Collision3D { namespace Utility
if( Intersect(box, sphere) )
{
Float distance;
Ray ray( box.center, sphere.center - box.center );
Ray ray( box.center, (sphere.center - box.center).Normalize() );
Intersect( sphere, ray, distance );
worldPointOfContact = ray.origin + ray.direction*distance;

View File

@ -50,7 +50,12 @@ void RigidBody::Update_LeapFrog( Float updateFrameLength )
// updating the linear
// ds = dt * Formula::LinearVelocity( m, avg_G ) = dt * avg_G / m = (dt / m) * avg_G
this->centerPos += ( updateFrameLength / this->mass ) * AverageWithDelta( this->momentum_Linear, this->impulse_Linear );
Float3 deltaPos = ( updateFrameLength / this->mass ) * AverageWithDelta( this->momentum_Linear, this->impulse_Linear );
if( deltaPos.GetLength() < 0.001f )
{
deltaPos = Float3::null;
}
this->centerPos += deltaPos;
// updating the angular
// dO = dt * Formula::AngularVelocity( (RI)^-1, avg_H ) = dt * (RI)^-1 * avg_H