本文整理汇总了C++中RunPhysics函数的典型用法代码示例。如果您正苦于以下问题:C++ RunPhysics函数的具体用法?C++ RunPhysics怎么用?C++ RunPhysics使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RunPhysics函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
/*
=================
idEntityFx::ClientPredictionThink
=================
*/
void idEntityFx::ClientPredictionThink( void ) {
if ( gameLocal.isNewFrame ) {
Run( gameLocal.time );
}
RunPhysics();
Present();
}
示例2: RunPhysics
void hhProjectileSoulCannon::Think( void ) {
// run physics
RunPhysics();
// Thrust toward enemy
if ( thinkFlags & TH_THINK && thrustDir != vec3_origin ) {
idVec3 vel = GetPhysics()->GetLinearVelocity();
vel += thrustDir * spawnArgs.GetFloat( "soulThrust", "5.0" );
if ( vel.Length() > maxVelocity ) { // Cap the velocity
vel.Normalize();
vel *= maxVelocity;
}
GetPhysics()->SetLinearVelocity( vel );
GetPhysics()->SetAxis( vel.ToMat3() );
}
//HUMANHEAD: aob
if (thinkFlags & TH_TICKER) {
Ticker();
}
//HUMANHEAD
Present();
}
示例3: Think
/*
=================
rvEffect::ClientPredictionThink
=================
*/
void rvEffect::ClientPredictionThink( void ) {
if ( gameLocal.isNewFrame ) {
Think ( );
}
RunPhysics();
Present();
}
示例4: BecomeInactive
/*
================
idLight::Think
================
*/
void idLight::Think( void ) {
idVec4 color;
if ( thinkFlags & TH_THINK )
{
if ( fadeEnd > 0 )
{
if ( gameLocal.time < fadeEnd )
{
color.Lerp( fadeFrom, fadeTo, ( float )( gameLocal.time - fadeStart ) / ( float )( fadeEnd - fadeStart ) );
}
else
{
color = fadeTo;
fadeEnd = 0;
BecomeInactive( TH_THINK );
}
SetColor( color );
}
}
RunPhysics();
Present();
}
示例5: RunPhysics
/*
================
idSound::Think
================
*/
void idSound::Think( void ) {
idAngles ang;
// run physics
RunPhysics();
// clear out our update visuals think flag since we never call Present
BecomeInactive( TH_UPDATEVISUALS );
}
示例6: Run
/*
================
idEntityFx::Think
Clears any visual fx started when {item,mob,player} was spawned
================
*/
void idEntityFx::Think(void) {
if (g_skipFX.GetBool()) {
return;
}
if (thinkFlags & TH_THINK) {
Run(gameLocal.time);
}
RunPhysics();
Present();
}
示例7: RunPhysics
void rvVehicleSpline::Event_SetSpline ( idEntity * spline ) {
if ( spline && spline->IsType( idSplinePath::GetClassType() ) ) {
physicsObj.SetSplineEntity( static_cast< idSplinePath * >( spline ) );
//HACK: force an intitial physics update so that the object orients itself with the spline
//TEMP: this should be fixed after the build on friday (Jan 28, 2005)
physicsObj.SetSpeed( 0.1f );
RunPhysics();
//END HACK
}
}
示例8: RemoveShard
/*
================
idBrittleFracture::Think
================
*/
void idBrittleFracture::Think( void ) {
int i, startTime, endTime, droppedTime;
shard_t *shard;
bool atRest = true, fading = false;
// remove overdue shards
for( i = 0; i < shards.Num(); i++ ) {
droppedTime = shards[i]->droppedTime;
if( droppedTime != -1 ) {
if( gameLocal.time - droppedTime > SHARD_ALIVE_TIME ) {
RemoveShard( i );
i--;
}
fading = true;
}
}
// remove the entity when nothing is visible
if( !shards.Num() ) {
PostEventMS( &EV_Remove, 0 );
return;
}
if( thinkFlags & TH_PHYSICS ) {
startTime = gameLocal.previousTime;
endTime = gameLocal.time;
// run physics on shards
for( i = 0; i < shards.Num(); i++ ) {
shard = shards[i];
if( shard->droppedTime == -1 ) {
continue;
}
shard->physicsObj.Evaluate( endTime - startTime, endTime );
if( !shard->physicsObj.IsAtRest() ) {
atRest = false;
}
}
if( atRest ) {
BecomeInactive( TH_PHYSICS );
} else {
BecomeActive( TH_PHYSICS );
}
}
if( !atRest || bounds.IsCleared() ) {
bounds.Clear();
for( i = 0; i < shards.Num(); i++ ) {
bounds.AddBounds( shards[i]->clipModel->GetAbsBounds() );
}
}
if( fading ) {
BecomeActive( TH_UPDATEVISUALS | TH_THINK );
} else {
BecomeInactive( TH_THINK );
}
RunPhysics();
Present();
}
示例9: IsAtRest
/*
================
idBarrel::BarrelThink
================
*/
void idBarrel::BarrelThink(void) {
bool wasAtRest, onGround;
float movedDistance, rotatedDistance, angle;
idVec3 curOrigin, gravityNormal, dir;
idMat3 curAxis, axis;
wasAtRest = IsAtRest();
// run physics
RunPhysics();
// only need to give the visual model an additional rotation if the physics were run
if (!wasAtRest) {
// current physics state
onGround = GetPhysics()->HasGroundContacts();
curOrigin = GetPhysics()->GetOrigin();
curAxis = GetPhysics()->GetAxis();
// if the barrel is on the ground
if (onGround) {
gravityNormal = GetPhysics()->GetGravityNormal();
dir = curOrigin - lastOrigin;
dir -= gravityNormal * dir * gravityNormal;
movedDistance = dir.LengthSqr();
// if the barrel moved and the barrel is not aligned with the gravity direction
if (movedDistance > 0.0f && idMath::Fabs(gravityNormal * curAxis[barrelAxis]) < 0.7f) {
// barrel movement since last think frame orthogonal to the barrel axis
movedDistance = idMath::Sqrt(movedDistance);
dir *= 1.0f / movedDistance;
movedDistance = (1.0f - idMath::Fabs(dir * curAxis[barrelAxis])) * movedDistance;
// get rotation about barrel axis since last think frame
angle = lastAxis[(barrelAxis + 1) % 3] * curAxis[(barrelAxis + 1) % 3];
angle = idMath::ACos(angle);
// distance along cylinder hull
rotatedDistance = angle * radius;
// if the barrel moved further than it rotated about it's axis
if (movedDistance > rotatedDistance) {
// additional rotation of the visual model to make it look
// like the barrel rolls instead of slides
angle = 180.0f * (movedDistance - rotatedDistance) / (radius * idMath::PI);
if (gravityNormal.Cross(curAxis[barrelAxis]) * dir < 0.0f) {
additionalRotation += angle;
}
else {
additionalRotation -= angle;
}
dir = vec3_origin;
dir[barrelAxis] = 1.0f;
additionalAxis = idRotation(vec3_origin, dir, additionalRotation).ToMat3();
}
}
}
// save state for next think
lastOrigin = curOrigin;
lastAxis = curAxis;
}
Present();
}
示例10: DrawFov
/*
================
idSecurityCamera::Think
================
*/
void idSecurityCamera::Think( void ) {
float pct;
float travel;
if( thinkFlags & TH_THINK ) {
if( g_showEntityInfo.GetBool() ) {
DrawFov();
}
if( health <= 0 ) {
BecomeInactive( TH_THINK );
return;
}
}
// run physics
RunPhysics();
if( thinkFlags & TH_THINK ) {
if( CanSeePlayer() ) {
if( alertMode == SCANNING ) {
float sightTime;
SetAlertMode( ALERT );
stopSweeping = gameLocal.time;
if( sweeping ) {
CancelEvents( &EV_SecurityCam_Pause );
} else {
CancelEvents( &EV_SecurityCam_ReverseSweep );
}
sweeping = false;
StopSound( SND_CHANNEL_ANY, false );
StartSound( "snd_sight", SND_CHANNEL_BODY, 0, false, NULL );
sightTime = spawnArgs.GetFloat( "sightTime", "5" );
PostEventSec( &EV_SecurityCam_Alert, sightTime );
}
} else {
if( alertMode == ALERT ) {
float sightResume;
SetAlertMode( LOSINGINTEREST );
CancelEvents( &EV_SecurityCam_Alert );
sightResume = spawnArgs.GetFloat( "sightResume", "1.5" );
PostEventSec( &EV_SecurityCam_ContinueSweep, sightResume );
}
if( sweeping ) {
idAngles a = GetPhysics()->GetAxis().ToAngles();
pct = ( gameLocal.time - sweepStart ) / ( sweepEnd - sweepStart );
travel = pct * sweepAngle;
if( negativeSweep ) {
a.yaw = angle + travel;
} else {
a.yaw = angle - travel;
}
SetAngles( a );
}
}
}
Present();
}
示例11: RunPhysics
void hhControlHand::ClientPredictionThink( void ) {
RunPhysics();
// HUMANHEAD pdm
if (thinkFlags & TH_TICKER) {
Ticker();
}
UpdateAnimation();
UpdateVisuals();
Present();
}
示例12: RunPhysics
/*
================
idMoveableItem::Think
================
*/
void idMoveableItem::Think( void ) {
RunPhysics();
if ( thinkFlags & TH_PHYSICS ) {
// update trigger position
trigger->Link( gameLocal.clip, this, 0, GetPhysics()->GetOrigin(), mat3_identity );
}
// ---> sikk - Moveable Item Spinning
if ( thinkFlags & TH_THINK ) {
if ( spawnArgs.GetBool( "spin" ) || spawnArgs.GetBool( "fixedAxis" ) ) {
idMat3 axis;
axis.Identity();
GetPhysics()->SetAngularVelocity( vec3_zero );
GetPhysics()->SetAxis( axis );
if ( spawnArgs.GetBool( "spin" ) ) {
idAngles ang;
idVec3 org;
// item rotation
ang.pitch = ang.roll = 0.0f;
ang.yaw = ( gameLocal.time & 4095 ) * 360.0f / -4096.0f;
renderEntity.axis = ang.ToMat3();
// item bobbing
float scale = 0.005f;
org = GetPhysics()->GetOrigin();
org.z += 4.0f + cos( ( gameLocal.time * scale + entityNumber ) ) * 4.0f;
renderEntity.origin = org;
}
}
}
// <--- sikk - Moveable Item Spinning
if ( thinkFlags & TH_UPDATEPARTICLES ) {
if ( !gameLocal.smokeParticles->EmitSmoke( smoke, smokeTime, gameLocal.random.CRandomFloat(), GetPhysics()->GetOrigin(), GetPhysics()->GetAxis() ) ) {
// ---> sikk - continuous smoke particles (for gibs)
if ( repeatSmoke && GetPhysics()->GetLinearVelocity().Length() > 100.0f ) {
smokeTime = gameLocal.time;
} else {
smokeTime = 0;
BecomeInactive( TH_UPDATEPARTICLES );
}
// <--- sikk - continuous smoke particles (for gibs)
}
}
Present();
}
示例13: RunPhysics
void idActor::Think( void ) {
if ( thinkFlags & TH_THINK ) {
// clear the ik before we do anything else so the skeleton doesn't get updated twice
walkIK.ClearJointMods();
RunPhysics();
}
UpdateAnimation();
Present();
}
示例14: Run
/*
================
idEntityFx::Think
Clears any visual fx started when {item,mob,player} was spawned
================
*/
void idEntityFx::Think( void ) {
if ( g_skipFX.GetBool() ) {
return;
}
//gameLocal.Printf( "idEntityFx::Think of '%s'\n", GetName() );
if ( thinkFlags & TH_THINK ) {
Run( gameLocal.time );
}
RunPhysics();
Present();
}
示例15: CalculateNewDT
void World::Simulate(bool simRunning)
{
float frame_dt = CalculateNewDT();
//system updates
#if !ANGEL_MOBILE
theControllerManager.UpdateState();
_console->Update( (float)frame_dt );
#endif
// Must be called once per frame.
theSound.Update();
//make sure the game manager gets updates first, if we have one
if (_gameManager)
{
_gameManager->Update(frame_dt);
}
if (simRunning)
{
// Deliver any messages that have been queued from the last frame.
theSwitchboard.SendAllMessages();
RunPhysics(frame_dt);
//Flag that the _elements array is locked so we don't try to add any
// new actors during the update.
_elementsLocked = true;
UpdateRenderables(frame_dt);
CleanupRenderables();
_elementsLocked = false;
// Now that we're done updating the list, allow any deferred Adds to be processed.
ProcessDeferredAdds();
ProcessDeferredLayerChanges();
ProcessDeferredRemoves();
theSwitchboard.Update(frame_dt);
UpdateDebugItems(frame_dt);
//if there are any system updates that still need to be run, put them here
}
//making this the last update so we can accurately lock on position for rendering
theCamera.Update(frame_dt);
}