mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-05 16:45:34 +00:00
Box size set; Set speed
This commit is contained in:
parent
192d634098
commit
0fa1dea6c1
4 changed files with 28 additions and 12 deletions
|
@ -36,6 +36,10 @@ namespace Physic
|
||||||
mEngine->addRigidBody(mBody, false); //Add rigid body to dynamics world, but do not add to object map
|
mEngine->addRigidBody(mBody, false); //Add rigid body to dynamics world, but do not add to object map
|
||||||
pmove = new playerMove;
|
pmove = new playerMove;
|
||||||
pmove->mEngine = mEngine;
|
pmove->mEngine = mEngine;
|
||||||
|
btBoxShape* box = static_cast<btBoxShape*> (mBody->getCollisionShape());
|
||||||
|
btVector3 size = box->getHalfExtentsWithMargin();
|
||||||
|
Ogre::Vector3 halfExtents = Ogre::Vector3(size.getX(), size.getY(), size.getZ());
|
||||||
|
pmove->ps.halfExtents = halfExtents;
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicActor::~PhysicActor()
|
PhysicActor::~PhysicActor()
|
||||||
|
@ -59,6 +63,11 @@ namespace Physic
|
||||||
pmove->ps.gravity = gravity;
|
pmove->ps.gravity = gravity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PhysicActor::setSpeed(float speed)
|
||||||
|
{
|
||||||
|
pmove->ps.speed = speed;
|
||||||
|
}
|
||||||
|
|
||||||
void PhysicActor::enableCollisions(bool collision)
|
void PhysicActor::enableCollisions(bool collision)
|
||||||
{
|
{
|
||||||
collisionMode = collision;
|
collisionMode = collision;
|
||||||
|
@ -137,6 +146,10 @@ namespace Physic
|
||||||
//Create the newly scaled rigid body
|
//Create the newly scaled rigid body
|
||||||
mBody = mEngine->createAndAdjustRigidBody(mMesh, mName, scale, position, rotation);
|
mBody = mEngine->createAndAdjustRigidBody(mMesh, mName, scale, position, rotation);
|
||||||
mEngine->addRigidBody(mBody, false); //Add rigid body to dynamics world, but do not add to object map
|
mEngine->addRigidBody(mBody, false); //Add rigid body to dynamics world, but do not add to object map
|
||||||
|
btBoxShape* box = static_cast<btBoxShape*> (mBody->getCollisionShape());
|
||||||
|
btVector3 size = box->getHalfExtentsWithMargin();
|
||||||
|
Ogre::Vector3 halfExtents = Ogre::Vector3(size.getX(), size.getY(), size.getZ());
|
||||||
|
pmove->ps.halfExtents = halfExtents;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicActor::runPmove(){
|
void PhysicActor::runPmove(){
|
||||||
|
|
|
@ -81,6 +81,8 @@ namespace Physic
|
||||||
|
|
||||||
void setGravity(float gravity);
|
void setGravity(float gravity);
|
||||||
|
|
||||||
|
void setSpeed(float speed);
|
||||||
|
|
||||||
void setJumpVelocity(float velocity);
|
void setJumpVelocity(float velocity);
|
||||||
|
|
||||||
void enableCollisions(bool collision);
|
void enableCollisions(bool collision);
|
||||||
|
|
|
@ -231,7 +231,7 @@ bool PM_SlideMove( bool gravity )
|
||||||
// see if we can make it there
|
// see if we can make it there
|
||||||
//pm->trace ( &trace, pm->ps->origin, pm->mins, pm->maxs, end, pm->ps->clientNum, pm->tracemaskg);
|
//pm->trace ( &trace, pm->ps->origin, pm->mins, pm->maxs, end, pm->ps->clientNum, pm->tracemaskg);
|
||||||
//tracefunc(&trace, *(const D3DXVECTOR3* const)&(pm->ps.origin), *(const D3DXVECTOR3* const)&(end), *(const D3DXVECTOR3* const)&(pm->ps.velocity), 0, pml.traceObj);
|
//tracefunc(&trace, *(const D3DXVECTOR3* const)&(pm->ps.origin), *(const D3DXVECTOR3* const)&(end), *(const D3DXVECTOR3* const)&(pm->ps.velocity), 0, pml.traceObj);
|
||||||
newtrace(&trace, pm->ps.origin, end, halfExtents, Ogre::Math::DegreesToRadians (pm->ps.viewangles.y), pm->isInterior, pm->mEngine);
|
newtrace(&trace, pm->ps.origin, end, pm->ps.halfExtents, Ogre::Math::DegreesToRadians (pm->ps.viewangles.y), pm->isInterior, pm->mEngine);
|
||||||
|
|
||||||
if (trace.allsolid)
|
if (trace.allsolid)
|
||||||
{
|
{
|
||||||
|
@ -449,7 +449,7 @@ int PM_StepSlideMove( bool gravity )
|
||||||
//pm->trace (&trace, start_o, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask);
|
//pm->trace (&trace, start_o, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask);
|
||||||
//tracefunc(&trace, start_o, down, , 0, pml.scene);
|
//tracefunc(&trace, start_o, down, , 0, pml.scene);
|
||||||
//tracefunc(&trace, *(const D3DXVECTOR3* const)&start_o, *(const D3DXVECTOR3* const)&down, D3DXVECTOR3(0.0f, -STEPSIZE, 0.0f), 0, pml.traceObj);
|
//tracefunc(&trace, *(const D3DXVECTOR3* const)&start_o, *(const D3DXVECTOR3* const)&down, D3DXVECTOR3(0.0f, -STEPSIZE, 0.0f), 0, pml.traceObj);
|
||||||
newtrace(&trace, down, start_o, halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine);
|
newtrace(&trace, down, start_o, pm->ps.halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine);
|
||||||
|
|
||||||
// up = vec3(0, 0, 1)
|
// up = vec3(0, 0, 1)
|
||||||
//VectorSet(up, 0, 0, 1);
|
//VectorSet(up, 0, 0, 1);
|
||||||
|
@ -479,7 +479,7 @@ int PM_StepSlideMove( bool gravity )
|
||||||
// test the player position if they were a stepheight higher
|
// test the player position if they were a stepheight higher
|
||||||
//pm->trace (&trace, start_o, pm->mins, pm->maxs, up, pm->ps->clientNum, pm->tracemask);
|
//pm->trace (&trace, start_o, pm->mins, pm->maxs, up, pm->ps->clientNum, pm->tracemask);
|
||||||
//tracefunc(&trace, *(const D3DXVECTOR3* const)&start_o, *(const D3DXVECTOR3* const)&up, D3DXVECTOR3(0.0f, STEPSIZE, 0.0f), 0, pml.traceObj);
|
//tracefunc(&trace, *(const D3DXVECTOR3* const)&start_o, *(const D3DXVECTOR3* const)&up, D3DXVECTOR3(0.0f, STEPSIZE, 0.0f), 0, pml.traceObj);
|
||||||
newtrace(&trace, start_o, up, halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine);
|
newtrace(&trace, start_o, up, pm->ps.halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine);
|
||||||
if ( trace.allsolid )
|
if ( trace.allsolid )
|
||||||
{
|
{
|
||||||
//if ( pm->debugLevel )
|
//if ( pm->debugLevel )
|
||||||
|
@ -510,7 +510,7 @@ int PM_StepSlideMove( bool gravity )
|
||||||
|
|
||||||
//pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask);
|
//pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask);
|
||||||
//tracefunc(&trace, *(const D3DXVECTOR3* const)&(pm->ps.origin), *(const D3DXVECTOR3* const)&down, D3DXVECTOR3(0.0f, -STEPSIZE, 0.0f), 0, pml.traceObj);
|
//tracefunc(&trace, *(const D3DXVECTOR3* const)&(pm->ps.origin), *(const D3DXVECTOR3* const)&down, D3DXVECTOR3(0.0f, -STEPSIZE, 0.0f), 0, pml.traceObj);
|
||||||
newtrace(&trace, pm->ps.origin, down, halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine);
|
newtrace(&trace, pm->ps.origin, down, pm->ps.halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine);
|
||||||
if ( !trace.allsolid )
|
if ( !trace.allsolid )
|
||||||
//VectorCopy (trace.endpos, pm->ps->origin);
|
//VectorCopy (trace.endpos, pm->ps->origin);
|
||||||
pm->ps.origin = trace.endpos;
|
pm->ps.origin = trace.endpos;
|
||||||
|
@ -902,7 +902,7 @@ static void PM_WalkMove( playerMove* const pmove )
|
||||||
if (pmove->hasWater )
|
if (pmove->hasWater )
|
||||||
{
|
{
|
||||||
const float waterHeight = pmove->waterHeight;
|
const float waterHeight = pmove->waterHeight;
|
||||||
const float waterSoundStepHeight = waterHeight + halfExtents.y;
|
const float waterSoundStepHeight = waterHeight + pm->ps.halfExtents.y;
|
||||||
if (pmove->ps.origin.y < waterSoundStepHeight)
|
if (pmove->ps.origin.y < waterSoundStepHeight)
|
||||||
step_underwater = true;
|
step_underwater = true;
|
||||||
}
|
}
|
||||||
|
@ -1182,7 +1182,7 @@ void PM_GroundTraceMissed()
|
||||||
|
|
||||||
//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, pm->ps.halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine);
|
||||||
//It hit the ground below
|
//It hit the ground below
|
||||||
if ( trace.fraction < 1.0 && pm->ps.origin.z > trace.endpos.z)
|
if ( trace.fraction < 1.0 && pm->ps.origin.z > trace.endpos.z)
|
||||||
{
|
{
|
||||||
|
@ -1228,7 +1228,7 @@ static bool PM_CorrectAllSolid(traceResults* const trace)
|
||||||
|
|
||||||
//pm->trace (trace, point, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask);
|
//pm->trace (trace, point, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask);
|
||||||
//tracefunc(trace, *(const D3DXVECTOR3* const)&point, *(const D3DXVECTOR3* const)&point, D3DXVECTOR3(0.0f, 0.0f, 0.0f), 0, pml.traceObj);
|
//tracefunc(trace, *(const D3DXVECTOR3* const)&point, *(const D3DXVECTOR3* const)&point, D3DXVECTOR3(0.0f, 0.0f, 0.0f), 0, pml.traceObj);
|
||||||
newtrace(trace, point, point, halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine);
|
newtrace(trace, point, point, pm->ps.halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine);
|
||||||
|
|
||||||
if ( !trace->allsolid )
|
if ( !trace->allsolid )
|
||||||
{
|
{
|
||||||
|
@ -1240,7 +1240,7 @@ static bool PM_CorrectAllSolid(traceResults* const trace)
|
||||||
|
|
||||||
//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, -0.25f, 0.0f), 0, pml.traceObj);
|
//tracefunc(trace, *(const D3DXVECTOR3* const)&(pm->ps.origin), *(const D3DXVECTOR3* const)&point, D3DXVECTOR3(0.0f, -0.25f, 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, pm->ps.halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine);
|
||||||
pml.groundTrace = *trace;
|
pml.groundTrace = *trace;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1341,7 +1341,7 @@ static void PM_CrashLand( void )
|
||||||
{
|
{
|
||||||
|
|
||||||
const float waterHeight = pm->waterHeight;
|
const float waterHeight = pm->waterHeight;
|
||||||
const float waterHeightSplash = waterHeight + halfExtents.y;
|
const float waterHeightSplash = waterHeight + pm->ps.halfExtents.y;
|
||||||
if (pm->ps.origin.z < waterHeightSplash)
|
if (pm->ps.origin.z < waterHeightSplash)
|
||||||
{
|
{
|
||||||
splashSound = true;
|
splashSound = true;
|
||||||
|
@ -1416,7 +1416,7 @@ static void PM_GroundTrace( void )
|
||||||
|
|
||||||
//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, -0.25f, 0.0f), 0, pml.traceObj);
|
//tracefunc(&trace, *(const D3DXVECTOR3* const)&(pm->ps.origin), *(const D3DXVECTOR3* const)&point, D3DXVECTOR3(0.0f, -0.25f, 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, pm->ps.halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine);
|
||||||
pml.groundTrace = trace;
|
pml.groundTrace = trace;
|
||||||
|
|
||||||
// do something corrective if the trace starts in a solid...
|
// do something corrective if the trace starts in a solid...
|
||||||
|
|
|
@ -23,7 +23,7 @@ Quake 3 Arena is copyright (C) 1999-2005 Id Software, Inc.
|
||||||
extern SceneInstance* global_lastscene;
|
extern SceneInstance* global_lastscene;
|
||||||
#endif*/
|
#endif*/
|
||||||
|
|
||||||
static const Ogre::Vector3 halfExtents(14.64f * 2, 14.24f * 2, 33.25f * 2);
|
static const Ogre::Vector3 halfExtentsDefault(14.64f * 2, 14.24f * 2, 33.25f * 2);
|
||||||
|
|
||||||
#define MAX_CLIP_PLANES 5
|
#define MAX_CLIP_PLANES 5
|
||||||
#define OVERCLIP 1.001f
|
#define OVERCLIP 1.001f
|
||||||
|
@ -89,7 +89,7 @@ struct playerMove
|
||||||
{
|
{
|
||||||
struct playerStruct
|
struct playerStruct
|
||||||
{
|
{
|
||||||
playerStruct() : gravity(800.0f), speed(480.0f), jump_velocity(270), pmove_framecount(20), groundEntityNum(ENTITYNUM_NONE), commandTime(40), move_type(PM_NOCLIP), pm_time(0), snappingImplemented(true), bSnap(false), counter(-1)
|
playerStruct() : gravity(800.0f), speed(480.0f), jump_velocity(270), pmove_framecount(20), groundEntityNum(ENTITYNUM_NONE), commandTime(40), move_type(PM_NOCLIP), pm_time(0), snappingImplemented(true), bSnap(false), counter(-1), halfExtents(halfExtentsDefault)
|
||||||
{
|
{
|
||||||
origin = Ogre::Vector3(0.0f, 0.0f, 0.0f);
|
origin = Ogre::Vector3(0.0f, 0.0f, 0.0f);
|
||||||
velocity = Ogre::Vector3(0.0f, 0.0f, 0.0f);
|
velocity = Ogre::Vector3(0.0f, 0.0f, 0.0f);
|
||||||
|
@ -116,6 +116,7 @@ struct playerMove
|
||||||
|
|
||||||
Ogre::Vector3 velocity;
|
Ogre::Vector3 velocity;
|
||||||
Ogre::Vector3 origin;
|
Ogre::Vector3 origin;
|
||||||
|
Ogre::Vector3 halfExtents;
|
||||||
bool bSnap;
|
bool bSnap;
|
||||||
bool snappingImplemented;
|
bool snappingImplemented;
|
||||||
int counter;
|
int counter;
|
||||||
|
|
Loading…
Reference in a new issue