mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:23:52 +00:00
Merge branch 'physicsaedra2' of https://github.com/jhooks1/openmw into physicsaedra2
This commit is contained in:
commit
2c89306306
4 changed files with 57 additions and 36 deletions
|
@ -28,6 +28,8 @@ namespace MWWorld
|
||||||
mEngine = new OEngine::Physic::PhysicEngine(shapeLoader);
|
mEngine = new OEngine::Physic::PhysicEngine(shapeLoader);
|
||||||
playerphysics->mEngine = mEngine;
|
playerphysics->mEngine = mEngine;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicsSystem::~PhysicsSystem()
|
PhysicsSystem::~PhysicsSystem()
|
||||||
|
|
|
@ -417,7 +417,7 @@ int PM_StepSlideMove( bool gravity )
|
||||||
Ogre::Vector3 up, down;
|
Ogre::Vector3 up, down;
|
||||||
float stepSize;
|
float stepSize;
|
||||||
|
|
||||||
|
std::cout << "StepSlideMove\n";
|
||||||
// start_o = pm->ps->origin
|
// start_o = pm->ps->origin
|
||||||
//VectorCopy (pm->ps->origin, start_o);
|
//VectorCopy (pm->ps->origin, start_o);
|
||||||
start_o = pm->ps.origin;
|
start_o = pm->ps.origin;
|
||||||
|
@ -516,6 +516,7 @@ int PM_StepSlideMove( bool gravity )
|
||||||
delta = pm->ps.origin.z - start_o.z;
|
delta = pm->ps.origin.z - start_o.z;
|
||||||
if ( delta > 2 )
|
if ( delta > 2 )
|
||||||
{
|
{
|
||||||
|
pm->ps.counter = 10;
|
||||||
if (gravity)
|
if (gravity)
|
||||||
printf("g on: %f ", delta);
|
printf("g on: %f ", delta);
|
||||||
else
|
else
|
||||||
|
@ -688,6 +689,7 @@ static bool PM_CheckJump(void)
|
||||||
|
|
||||||
pm->ps.groundEntityNum = ENTITYNUM_NONE;
|
pm->ps.groundEntityNum = ENTITYNUM_NONE;
|
||||||
pm->ps.velocity.z = JUMP_VELOCITY;
|
pm->ps.velocity.z = JUMP_VELOCITY;
|
||||||
|
pm->ps.bSnap = false;
|
||||||
//PM_AddEvent( EV_JUMP );
|
//PM_AddEvent( EV_JUMP );
|
||||||
|
|
||||||
/*if ( pm->cmd.forwardmove >= 0 )
|
/*if ( pm->cmd.forwardmove >= 0 )
|
||||||
|
@ -840,7 +842,7 @@ static void PM_WalkMove( playerMove* const pmove )
|
||||||
playerMove::playercmd cmd;
|
playerMove::playercmd cmd;
|
||||||
float accelerate;
|
float accelerate;
|
||||||
float vel;
|
float vel;
|
||||||
|
//pm->ps.gravity = 4000;
|
||||||
|
|
||||||
if ( pm->ps.waterlevel > 2 && //DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 )
|
if ( pm->ps.waterlevel > 2 && //DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 )
|
||||||
pml.forward.dotProduct(pml.groundTrace.planenormal) > 0.0f)
|
pml.forward.dotProduct(pml.groundTrace.planenormal) > 0.0f)
|
||||||
|
@ -1142,9 +1144,7 @@ void PM_GroundTraceMissed()
|
||||||
{
|
{
|
||||||
traceResults trace;
|
traceResults trace;
|
||||||
Ogre::Vector3 point;
|
Ogre::Vector3 point;
|
||||||
|
std::cout << "Ground trace missed\n";
|
||||||
if ( pm->ps.groundEntityNum != ENTITYNUM_NONE )
|
|
||||||
{
|
|
||||||
// we just transitioned into freefall
|
// we just transitioned into freefall
|
||||||
//if ( pm->debugLevel )
|
//if ( pm->debugLevel )
|
||||||
//Com_Printf("%i:lift\n", c_pmove);
|
//Com_Printf("%i:lift\n", c_pmove);
|
||||||
|
@ -1154,29 +1154,28 @@ void PM_GroundTraceMissed()
|
||||||
//VectorCopy( pm->ps->origin, point );
|
//VectorCopy( pm->ps->origin, point );
|
||||||
point = pm->ps.origin;
|
point = pm->ps.origin;
|
||||||
//point[2] -= 64;
|
//point[2] -= 64;
|
||||||
point.z -= 64;
|
point.z -= 32;
|
||||||
|
|
||||||
//pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask);
|
//pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask);
|
||||||
//tracefunc(&trace, *(const D3DXVECTOR3* const)&(pm->ps.origin), *(const D3DXVECTOR3* const)&point, D3DXVECTOR3(0.0f, -64.0f, 0.0f), 0, pml.traceObj);
|
//tracefunc(&trace, *(const D3DXVECTOR3* const)&(pm->ps.origin), *(const D3DXVECTOR3* const)&point, D3DXVECTOR3(0.0f, -64.0f, 0.0f), 0, pml.traceObj);
|
||||||
newtrace(&trace, pm->ps.origin, point, halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine);
|
newtrace(&trace, pm->ps.origin, point, halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine);
|
||||||
if ( trace.fraction == 1.0 )
|
//It hit the ground below
|
||||||
|
if ( trace.fraction < 1.0 && pm->ps.origin.z > trace.endpos.z)
|
||||||
{
|
{
|
||||||
if ( pm->cmd.forwardmove >= 0 )
|
pm->ps.origin = trace.endpos;
|
||||||
{
|
pml.walking = true;
|
||||||
//PM_ForceLegsAnim( LEGS_JUMP );
|
pml.groundPlane = true;
|
||||||
//pm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP;
|
pm->ps.groundEntityNum = trace.entityNum;
|
||||||
}
|
|
||||||
else
|
}
|
||||||
{
|
else{
|
||||||
//PM_ForceLegsAnim( LEGS_JUMPB );
|
pm->ps.groundEntityNum = ENTITYNUM_NONE;
|
||||||
//pm->ps->pm_flags |= PMF_BACKWARDS_JUMP;
|
pml.groundPlane = false;
|
||||||
}
|
pml.walking = false;
|
||||||
}
|
pm->ps.bSnap = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pm->ps.groundEntityNum = ENTITYNUM_NONE;
|
|
||||||
pml.groundPlane = false;
|
|
||||||
pml.walking = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool PM_CorrectAllSolid(traceResults* const trace)
|
static bool PM_CorrectAllSolid(traceResults* const trace)
|
||||||
|
@ -1404,19 +1403,26 @@ static void PM_GroundTrace( void )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// if the trace didn't hit anything, we are in free fall
|
||||||
// if the trace didn't hit anything, we are in free fall
|
if ( trace.fraction == 1.0)
|
||||||
if ( trace.fraction == 1.0 )
|
|
||||||
{
|
{
|
||||||
PM_GroundTraceMissed();
|
if(pm->ps.snappingImplemented){
|
||||||
pml.groundPlane = false;
|
if(pm->ps.bSnap && pm->ps.counter <= 0)
|
||||||
pml.walking = false;
|
PM_GroundTraceMissed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//It hit something, so we are on the ground
|
||||||
|
pm->ps.bSnap = true;
|
||||||
|
|
||||||
// check if getting thrown off the ground
|
}
|
||||||
|
// check if getting thrown off the ground
|
||||||
//if ( pm->ps->velocity[2] > 0 && DotProduct( pm->ps->velocity, trace.plane.normal ) > 10 )
|
//if ( pm->ps->velocity[2] > 0 && DotProduct( pm->ps->velocity, trace.plane.normal ) > 10 )
|
||||||
if (pm->ps.velocity.z > 0 && pm->ps.velocity.dotProduct(trace.planenormal) > 10.0f)
|
if (pm->ps.velocity.z > 0 && pm->ps.velocity.dotProduct(trace.planenormal) > 10.0f )
|
||||||
{
|
{
|
||||||
//if ( pm->debugLevel )
|
//if ( pm->debugLevel )
|
||||||
//Com_Printf("%i:kickoff\n", c_pmove);
|
//Com_Printf("%i:kickoff\n", c_pmove);
|
||||||
|
@ -1432,13 +1438,22 @@ static void PM_GroundTrace( void )
|
||||||
PM_ForceLegsAnim( LEGS_JUMPB );
|
PM_ForceLegsAnim( LEGS_JUMPB );
|
||||||
pm->ps->pm_flags |= PMF_BACKWARDS_JUMP;
|
pm->ps->pm_flags |= PMF_BACKWARDS_JUMP;
|
||||||
}*/
|
}*/
|
||||||
|
if(!pm->ps.bSnap){
|
||||||
pm->ps.groundEntityNum = ENTITYNUM_NONE;
|
pm->ps.groundEntityNum = ENTITYNUM_NONE;
|
||||||
pml.groundPlane = false;
|
pml.groundPlane = false;
|
||||||
pml.walking = false;
|
pml.walking = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pml.groundPlane = true;
|
||||||
|
pml.walking = true;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// slopes that are too steep will not be considered onground
|
// slopes that are too steep will not be considered onground
|
||||||
//if ( trace.plane.normal[2] < MIN_WALK_NORMAL )
|
//if ( trace.plane.normal[2] < MIN_WALK_NORMAL )
|
||||||
if (trace.planenormal.z < MIN_WALK_NORMAL)
|
if (trace.planenormal.z < MIN_WALK_NORMAL)
|
||||||
|
@ -1500,7 +1515,7 @@ void PM_AirMove()
|
||||||
float wishspeed;
|
float wishspeed;
|
||||||
float scale;
|
float scale;
|
||||||
playerMove::playercmd cmd;
|
playerMove::playercmd cmd;
|
||||||
|
//pm->ps.gravity = 800;
|
||||||
PM_Friction();
|
PM_Friction();
|
||||||
|
|
||||||
fmove = pm->cmd.forwardmove;
|
fmove = pm->cmd.forwardmove;
|
||||||
|
@ -1508,7 +1523,6 @@ void PM_AirMove()
|
||||||
|
|
||||||
cmd = pm->cmd;
|
cmd = pm->cmd;
|
||||||
scale = PM_CmdScale( &cmd );
|
scale = PM_CmdScale( &cmd );
|
||||||
|
|
||||||
// set the movementDir so clients can rotate the legs for strafing
|
// set the movementDir so clients can rotate the legs for strafing
|
||||||
//PM_SetMovementDir();
|
//PM_SetMovementDir();
|
||||||
|
|
||||||
|
@ -1730,6 +1744,7 @@ void PM_SetWaterLevel( playerMove* const pm )
|
||||||
pm->ps.waterlevel = WL_ANKLE;
|
pm->ps.waterlevel = WL_ANKLE;
|
||||||
//point[2] = pm->ps->origin[2] + MINS_Z + sample1;
|
//point[2] = pm->ps->origin[2] + MINS_Z + sample1;
|
||||||
point.z = pm->ps.origin.z + MINS_Z + sample1;
|
point.z = pm->ps.origin.z + MINS_Z + sample1;
|
||||||
|
checkWater = (pml.hasWater && pml.waterHeight > point.z);
|
||||||
//cont = pm->pointcontents (point, pm->ps->clientNum );
|
//cont = pm->pointcontents (point, pm->ps->clientNum );
|
||||||
//if ( cont & MASK_WATER )
|
//if ( cont & MASK_WATER )
|
||||||
if (checkWater)
|
if (checkWater)
|
||||||
|
@ -1739,6 +1754,7 @@ void PM_SetWaterLevel( playerMove* const pm )
|
||||||
point.z = pm->ps.origin.z + MINS_Z + sample2;
|
point.z = pm->ps.origin.z + MINS_Z + sample2;
|
||||||
//cont = pm->pointcontents (point, pm->ps->clientNum );
|
//cont = pm->pointcontents (point, pm->ps->clientNum );
|
||||||
//if ( cont & MASK_WATER )
|
//if ( cont & MASK_WATER )
|
||||||
|
checkWater = (pml.hasWater && pml.waterHeight > point.z);
|
||||||
if (checkWater )
|
if (checkWater )
|
||||||
pm->ps.waterlevel = WL_UNDERWATER;
|
pm->ps.waterlevel = WL_UNDERWATER;
|
||||||
}
|
}
|
||||||
|
@ -1747,7 +1763,7 @@ void PM_SetWaterLevel( playerMove* const pm )
|
||||||
|
|
||||||
void PmoveSingle (playerMove* const pmove)
|
void PmoveSingle (playerMove* const pmove)
|
||||||
{
|
{
|
||||||
|
pmove->ps.counter--;
|
||||||
//pm = pmove;
|
//pm = pmove;
|
||||||
|
|
||||||
// Aedra doesn't support Q3-style VM traps D: //while(1);
|
// Aedra doesn't support Q3-style VM traps D: //while(1);
|
||||||
|
|
|
@ -42,7 +42,7 @@ static const Ogre::Vector3 halfExtents(14.64f * 2, 14.24f * 2, 33.25f * 2);
|
||||||
#define ENTITYNUM_NONE (MAX_GENTITIES - 1)
|
#define ENTITYNUM_NONE (MAX_GENTITIES - 1)
|
||||||
#define ENTITYNUM_WORLD (MAX_GENTITIES - 2)
|
#define ENTITYNUM_WORLD (MAX_GENTITIES - 2)
|
||||||
#define MIN_WALK_NORMAL 0.7f // can't walk on very steep slopes
|
#define MIN_WALK_NORMAL 0.7f // can't walk on very steep slopes
|
||||||
#define JUMP_VELOCITY (270 * 1)
|
#define JUMP_VELOCITY (270)
|
||||||
#define PS_PMOVEFRAMECOUNTBITS 6
|
#define PS_PMOVEFRAMECOUNTBITS 6
|
||||||
#define MINS_Z -24
|
#define MINS_Z -24
|
||||||
#define DEFAULT_VIEWHEIGHT 26
|
#define DEFAULT_VIEWHEIGHT 26
|
||||||
|
@ -90,7 +90,7 @@ struct playerMove
|
||||||
{
|
{
|
||||||
struct playerStruct
|
struct playerStruct
|
||||||
{
|
{
|
||||||
playerStruct() : gravity(800.0f), speed(480.0f), pmove_framecount(20), groundEntityNum(ENTITYNUM_NONE), commandTime(40), move_type(PM_NOCLIP), pm_time(0)
|
playerStruct() : gravity(800.0f), speed(480.0f), pmove_framecount(20), groundEntityNum(ENTITYNUM_NONE), commandTime(40), move_type(PM_NOCLIP), pm_time(0), snappingImplemented(true), bSnap(false), counter(-1)
|
||||||
{
|
{
|
||||||
origin = Ogre::Vector3(733.164f,900.0f, 839.432f);
|
origin = Ogre::Vector3(733.164f,900.0f, 839.432f);
|
||||||
velocity = Ogre::Vector3(0.0f, 0.0f, 0.0f);
|
velocity = Ogre::Vector3(0.0f, 0.0f, 0.0f);
|
||||||
|
@ -117,6 +117,9 @@ struct playerMove
|
||||||
|
|
||||||
Ogre::Vector3 velocity;
|
Ogre::Vector3 velocity;
|
||||||
Ogre::Vector3 origin;
|
Ogre::Vector3 origin;
|
||||||
|
bool bSnap;
|
||||||
|
bool snappingImplemented;
|
||||||
|
int counter;
|
||||||
float gravity; // default = 800
|
float gravity; // default = 800
|
||||||
float speed; // default = 320
|
float speed; // default = 320
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ const bool NewPhysicsTrace(NewPhysTraceResults* const out, const Ogre::Vector3&
|
||||||
if (!TestPointAgainstAabb2(aabbMin, aabbMax, *(const btVector3* const)&(start) ) )
|
if (!TestPointAgainstAabb2(aabbMin, aabbMax, *(const btVector3* const)&(start) ) )
|
||||||
{
|
{
|
||||||
//We're solid
|
//We're solid
|
||||||
out->startSolid = false;
|
out->startSolid = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue