本文整理汇总了C++中idRotation::GetAngle方法的典型用法代码示例。如果您正苦于以下问题:C++ idRotation::GetAngle方法的具体用法?C++ idRotation::GetAngle怎么用?C++ idRotation::GetAngle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idRotation
的用法示例。
在下文中一共展示了idRotation::GetAngle方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Rotation
/*
================
idCollisionModelManagerLocal::Rotation
================
*/
void idCollisionModelManagerLocal::Rotation( trace_t *results, const idVec3 &start, const idRotation &rotation,
const idTraceModel *trm, const idMat3 &trmAxis, int contentMask,
cmHandle_t model, const idVec3 &modelOrigin, const idMat3 &modelAxis ) {
idVec3 tmp;
float maxa, stepa, a, lasta;
assert( ((byte *)&start) < ((byte *)results) || ((byte *)&start) > (((byte *)results) + sizeof( trace_t )) );
assert( ((byte *)&trmAxis) < ((byte *)results) || ((byte *)&trmAxis) > (((byte *)results) + sizeof( trace_t )) );
memset( results, 0, sizeof( *results ) );
// if special position test
if ( rotation.GetAngle() == 0.0f ) {
idCollisionModelManagerLocal::ContentsTrm( results, start, trm, trmAxis, contentMask, model, modelOrigin, modelAxis );
return;
}
if ( rotation.GetAngle() >= 180.0f || rotation.GetAngle() <= -180.0f) {
if ( rotation.GetAngle() >= 360.0f ) {
maxa = 360.0f;
stepa = 120.0f; // three steps strictly < 180 degrees
} else if ( rotation.GetAngle() <= -360.0f ) {
maxa = -360.0f;
stepa = -120.0f; // three steps strictly < 180 degrees
} else {
maxa = rotation.GetAngle();
stepa = rotation.GetAngle() * 0.5f; // two steps strictly < 180 degrees
}
for ( lasta = 0.0f, a = stepa; fabs( a ) < fabs( maxa ) + 1.0f; lasta = a, a += stepa ) {
// partial rotation
idCollisionModelManagerLocal::Rotation180( results, rotation.GetOrigin(), rotation.GetVec(), lasta, a, start, trm, trmAxis, contentMask, model, modelOrigin, modelAxis );
// if there is a collision
if ( results->fraction < 1.0f ) {
// fraction of total rotation
results->fraction = (lasta + stepa * results->fraction) / rotation.GetAngle();
return;
}
}
results->fraction = 1.0f;
return;
}
idCollisionModelManagerLocal::Rotation180( results, rotation.GetOrigin(), rotation.GetVec(), 0.0f, rotation.GetAngle(), start, trm, trmAxis, contentMask, model, modelOrigin, modelAxis );
#ifdef _DEBUG
// test for collisions
if ( cm_debugCollision.GetBool() ) {
// if the trm is stuck in the model
if ( idCollisionModelManagerLocal::Contents( results->endpos, trm, results->endAxis, -1, model, modelOrigin, modelAxis ) & contentMask ) {
trace_t tr;
// test where the trm is stuck in the model
idCollisionModelManagerLocal::Contents( results->endpos, trm, results->endAxis, -1, model, modelOrigin, modelAxis );
// re-run collision detection to find out where it failed
idCollisionModelManagerLocal::Rotation( &tr, start, rotation, trm, trmAxis, contentMask, model, modelOrigin, modelAxis );
}
}
#endif
}
示例2: FromPointRotation
/*
============
idBounds::FromPointRotation
Most tight bounds for the rotational movement of the given point.
============
*/
void idBounds::FromPointRotation( const idVec3 &point, const idRotation &rotation ) {
float radius;
if ( idMath::Fabs( rotation.GetAngle() ) < 180.0f ) {
(*this) = BoundsForPointRotation( point, rotation );
}
else {
radius = ( point - rotation.GetOrigin() ).Length();
// FIXME: these bounds are usually way larger
b[0].Set( -radius, -radius, -radius );
b[1].Set( radius, radius, radius );
}
}
示例3: FromBoundsRotation
/*
============
idBounds::FromBoundsRotation
Most tight bounds for the rotational movement of the given bounds.
============
*/
void idBounds::FromBoundsRotation( const idBounds &bounds, const idVec3 &origin, const idMat3 &axis, const idRotation &rotation ) {
int i;
float radius;
idVec3 point;
idBounds rBounds;
if ( idMath::Fabs( rotation.GetAngle() ) < 180.0f ) {
(*this) = BoundsForPointRotation( bounds[0] * axis + origin, rotation );
for ( i = 1; i < 8; i++ ) {
point[0] = bounds[(i^(i>>1))&1][0];
point[1] = bounds[(i>>1)&1][1];
point[2] = bounds[(i>>2)&1][2];
(*this) += BoundsForPointRotation( point * axis + origin, rotation );
}
}
示例4: Motion
/*
============
idClip::Motion
============
*/
bool idClip::Motion( trace_t &results, const idVec3 &start, const idVec3 &end, const idRotation &rotation,
const idClipModel *mdl, const idMat3 &trmAxis, int contentMask, const idEntity *passEntity ) {
int i, num;
idClipModel *touch, *clipModelList[MAX_GENTITIES];
idVec3 dir, endPosition;
idBounds traceBounds;
float radius;
trace_t translationalTrace, rotationalTrace, trace;
idRotation endRotation;
const idTraceModel *trm;
assert( rotation.GetOrigin() == start );
if ( TestHugeTranslation( results, mdl, start, end, trmAxis ) ) {
return true;
}
if ( mdl != NULL && rotation.GetAngle() != 0.0f && rotation.GetVec() != vec3_origin ) {
// if no translation
if ( start == end ) {
// pure rotation
return Rotation( results, start, rotation, mdl, trmAxis, contentMask, passEntity );
}
} else if ( start != end ) {
// pure translation
return Translation( results, start, end, mdl, trmAxis, contentMask, passEntity );
} else {
// no motion
results.fraction = 1.0f;
results.endpos = start;
results.endAxis = trmAxis;
return false;
}
trm = TraceModelForClipModel( mdl );
radius = trm->bounds.GetRadius();
if ( !passEntity || passEntity->entityNumber != ENTITYNUM_WORLD ) {
// translational collision with world
idClip::numTranslations++;
collisionModelManager->Translation( &translationalTrace, start, end, trm, trmAxis, contentMask, 0, vec3_origin, mat3_default );
translationalTrace.c.entityNum = translationalTrace.fraction != 1.0f ? ENTITYNUM_WORLD : ENTITYNUM_NONE;
} else {
memset( &translationalTrace, 0, sizeof( translationalTrace ) );
translationalTrace.fraction = 1.0f;
translationalTrace.endpos = end;
translationalTrace.endAxis = trmAxis;
}
if ( translationalTrace.fraction != 0.0f ) {
traceBounds.FromBoundsRotation( trm->bounds, start, trmAxis, rotation );
dir = translationalTrace.endpos - start;
for ( i = 0; i < 3; i++ ) {
if ( dir[i] < 0.0f ) {
traceBounds[0][i] += dir[i];
}
else {
traceBounds[1][i] += dir[i];
}
}
num = GetTraceClipModels( traceBounds, contentMask, passEntity, clipModelList );
for ( i = 0; i < num; i++ ) {
touch = clipModelList[i];
if ( !touch ) {
continue;
}
if ( touch->renderModelHandle != -1 ) {
idClip::numRenderModelTraces++;
TraceRenderModel( trace, start, end, radius, trmAxis, touch );
} else {
idClip::numTranslations++;
collisionModelManager->Translation( &trace, start, end, trm, trmAxis, contentMask,
touch->Handle(), touch->origin, touch->axis );
}
if ( trace.fraction < translationalTrace.fraction ) {
translationalTrace = trace;
translationalTrace.c.entityNum = touch->entity->entityNumber;
translationalTrace.c.id = touch->id;
if ( translationalTrace.fraction == 0.0f ) {
break;
}
}
}
} else {
num = -1;
}
endPosition = translationalTrace.endpos;
//.........这里部分代码省略.........
示例5: TryRotatePushEntity
int idPush::TryRotatePushEntity( trace_t &results, idEntity *check, idClipModel *clipModel, const int flags,
const idMat3 &newAxis, const idRotation &rotation ) {
trace_t trace;
idVec3 rotationPoint;
idRotation newRotation;
float checkAngle;
idPhysics *physics;
physics = check->GetPhysics();
#ifdef ROTATIONAL_PUSH_DEBUG
bool startsolid = false;
if ( physics->ClipContents( clipModel ) ) {
startsolid = true;
}
#endif
results.fraction = 1.0f;
results.endpos = clipModel->GetOrigin();
results.endAxis = newAxis;
memset( &results.c, 0, sizeof( results.c ) );
// always pushed when standing on the pusher
if ( physics->IsGroundClipModel( clipModel->GetEntity()->entityNumber, clipModel->GetId() ) ) {
// rotate the entity colliding with all other entities except the pusher itself
ClipEntityRotation( trace, check, NULL, clipModel, rotation );
// if there is a collision
if ( trace.fraction < 1.0f ) {
// angle along which the entity is pushed
checkAngle = rotation.GetAngle() * trace.fraction;
// test if the entity can stay at it's partly pushed position by rotating
// the entity in reverse only colliding with pusher
newRotation.Set( rotation.GetOrigin(), rotation.GetVec(), -(rotation.GetAngle() - checkAngle) );
ClipEntityRotation( results, check, clipModel, NULL, newRotation );
// if there is a collision
if ( results.fraction < 1.0f ) {
// FIXME: try to push the blocking entity as well or try to slide along collision plane(s)?
results.c.normal = -results.c.normal;
results.c.dist = -results.c.dist;
// the entity will be crushed between the pusher and some other entity
return PUSH_BLOCKED;
}
}
else {
// angle along which the entity is pushed
checkAngle = rotation.GetAngle();
}
// point to rotate entity bbox around back to axial
rotationPoint = physics->GetOrigin();
}
else {
// rotate entity in reverse only colliding with pusher
newRotation = rotation;
newRotation.Scale( -1 );
//
ClipEntityRotation( results, check, clipModel, NULL, newRotation );
// if no collision with the pusher then the entity is not pushed by the pusher
if ( results.fraction >= 1.0f ) {
#ifdef ROTATIONAL_PUSH_DEBUG
// set pusher into final position
clipModel->Link( gameLocal.clip, clipModel->GetEntity(), clipModel->GetId(), clipModel->GetOrigin(), newAxis );
if ( physics->ClipContents( clipModel ) ) {
if ( !startsolid ) {
int bah = 1;
}
}
#endif
return PUSH_NO;
}
// get point to rotate bbox around back to axial
rotationPoint = results.c.point;
// angle along which the entity will be pushed
checkAngle = rotation.GetAngle() * (1.0f - results.fraction);
// rotate the entity colliding with all other entities except the pusher itself
newRotation.Set( rotation.GetOrigin(), rotation.GetVec(), checkAngle );
ClipEntityRotation( trace, check, NULL, clipModel, newRotation );
// if there is a collision
if ( trace.fraction < 1.0f ) {
// FIXME: try to push the blocking entity as well or try to slide along collision plane(s)?
results.c.normal = -results.c.normal;
results.c.dist = -results.c.dist;
// the entity will be crushed between the pusher and some other entity
return PUSH_BLOCKED;
}
}
SaveEntityPosition( check );
newRotation.Set( rotation.GetOrigin(), rotation.GetVec(), checkAngle );
// NOTE: this code prevents msvc 6.0 & 7.0 from screwing up the above code in
// release builds moving less floats than it should
static float shit = checkAngle;
#pragma unused(shit)
//.........这里部分代码省略.........
示例6: ClipRotationalPush
/*
============
idPush::ClipRotationalPush
Try to push other entities by rotating the given entity.
============
*/
float idPush::ClipRotationalPush( trace_t &results, idEntity *pusher, const int flags,
const idMat3 &newAxis, const idRotation &rotation ) {
int i, j, numListedEntities;
idEntity *curPusher, *ent, *entityList[ MAX_GENTITIES ];
float fraction;
bool groundContact, blocked = false;
float totalMass;
trace_t trace;
idRotation realRotation, partialRotation;
idMat3 oldAxis;
totalMass = 0.0f;
results.fraction = 1.0f;
results.endpos = pusher->GetPhysics()->GetOrigin();
results.endAxis = newAxis;
memset( results.c, 0, sizeof( results.c ) );
if ( !rotation.GetAngle() ) {
return totalMass;
}
// clip against all non-pushable physics objects
if ( flags & PUSHFL_CLIP ) {
numListedEntities = GetPushableEntitiesForRotation( pusher, pusher, flags, rotation, entityList, MAX_GENTITIES );
// disable pushable entities for collision detection
for ( i = 0; i < numListedEntities; i++ ) {
entityList[i]->GetPhysics()->DisableClip();
}
// clip rotation
pusher->GetPhysics()->ClipRotation( results, rotation, NULL );
// enable pushable entities
for ( i = 0; i < numListedEntities; i++ ) {
entityList[i]->GetPhysics()->EnableClip();
}
if ( results.fraction == 0.0f ) {
return totalMass;
}
realRotation = results.fraction * rotation;
}
else {
realRotation = rotation;
}
// put the pusher in the group of pushed physics objects
pushedGroup[0].ent = pusher;
pushedGroup[0].fraction = 1.0f;
pushedGroup[0].groundContact = true;
pushedGroup[0].test = true;
pushedGroupSize = 1;
// get all physics objects that need to be pushed
for ( i = 0; i < pushedGroupSize; ) {
if ( !pushedGroup[i].test ) {
i++;
continue;
}
pushedGroup[i].test = false;
curPusher = pushedGroup[i].ent;
fraction = pushedGroup[i].fraction;
groundContact = pushedGroup[i].groundContact;
i = 0;
numListedEntities = GetPushableEntitiesForRotation( curPusher, pusher, flags, realRotation, entityList, MAX_GENTITIES );
for ( j = 0; j < numListedEntities; j++ ) {
ent = entityList[ j ];
if ( IsFullyPushed( ent ) ) {
continue;
}
if ( ent->GetPhysics()->IsGroundEntity( curPusher->entityNumber ) ) {
AddEntityToPushedGroup( ent, 1.0f * fraction, false );
}
else if ( ClipRotationAgainstPusher( trace, ent, curPusher, -fraction * realRotation ) ) {
AddEntityToPushedGroup( ent, ( 1.0f - trace.fraction ) * fraction, groundContact );
}
}
}
// save physics states and disable physics objects for collision detection
for ( i = 1; i < pushedGroupSize; i++ ) {
SaveEntityPosition( pushedGroup[i].ent );
pushedGroup[i].ent->GetPhysics()->DisableClip();
}
// clip all pushed physics objects
for ( i = 1; i < pushedGroupSize; i++ ) {
partialRotation = realRotation * pushedGroup[i].fraction;
pushedGroup[i].ent->GetPhysics()->ClipRotation( trace, partialRotation, NULL );
//.........这里部分代码省略.........