本文整理汇总了C++中Q_fabs函数的典型用法代码示例。如果您正苦于以下问题:C++ Q_fabs函数的具体用法?C++ Q_fabs怎么用?C++ Q_fabs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Q_fabs函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: CM_TraceThroughBounds
/*
================
CM_BoxDistanceFromPlane
================
*/
static int CM_TraceThroughBounds(traceWork_t *tw, vec3_t mins, vec3_t maxs)
{
if (mins[0] > tw->bounds[1][0] ||
maxs[0] < tw->bounds[0][0] ||
mins[1] > tw->bounds[1][1] ||
maxs[1] < tw->bounds[0][1] ||
mins[2] > tw->bounds[1][2] ||
maxs[2] < tw->bounds[0][2])
{
return qfalse;
}
{
vec3_t center, extents;
VectorAdd(mins, maxs, center);
VectorScale(center, 0.5f, center);
VectorSubtract(maxs, center, extents);
if (Q_fabs(CM_BoxDistanceFromPlane(center, extents, &tw->tracePlane1)) > tw->traceDist1)
{
return qfalse;
}
if (Q_fabs(CM_BoxDistanceFromPlane(center, extents, &tw->tracePlane2)) > tw->traceDist2)
{
return qfalse;
}
}
// trace might go through the bounds
return qtrue;
}
开发者ID:belstgut,项目名称:etlegacy,代码行数:36,代码来源:cm_trace.c
示例2: CM_DistanceFromLineSquared
/*
================
CM_DistanceFromLineSquared
================
*/
float CM_DistanceFromLineSquared(vec3_t p, vec3_t lp1, vec3_t lp2, vec3_t dir)
{
vec3_t proj, t;
int j;
CM_ProjectPointOntoVector(p, lp1, dir, proj);
for (j = 0; j < 3; j++)
if ((proj[j] > lp1[j] && proj[j] > lp2[j]) ||
(proj[j] < lp1[j] && proj[j] < lp2[j]))
{
break;
}
if (j < 3)
{
if (Q_fabs(proj[j] - lp1[j]) < Q_fabs(proj[j] - lp2[j]))
{
VectorSubtract(p, lp1, t);
}
else
{
VectorSubtract(p, lp2, t);
}
return VectorLengthSquared(t);
}
VectorSubtract(p, proj, t);
return VectorLengthSquared(t);
}
开发者ID:belstgut,项目名称:etlegacy,代码行数:32,代码来源:cm_trace.c
示例3: UI_MovedirAdjustment
/*
* UI_MovedirAdjustment
*/
static float
UI_MovedirAdjustment(Playerinfo *pi)
{
Vec3 relativeAngles;
Vec3 moveVector;
subv3(pi->viewAngles, pi->moveAngles, relativeAngles);
anglev3s(relativeAngles, moveVector, NULL, NULL);
if(Q_fabs(moveVector[0]) < 0.01)
moveVector[0] = 0.0;
if(Q_fabs(moveVector[1]) < 0.01)
moveVector[1] = 0.0;
if(moveVector[1] == 0 && moveVector[0] > 0)
return 0;
if(moveVector[1] < 0 && moveVector[0] > 0)
return 22;
if(moveVector[1] < 0 && moveVector[0] == 0)
return 45;
if(moveVector[1] < 0 && moveVector[0] < 0)
return -22;
if(moveVector[1] == 0 && moveVector[0] < 0)
return 0;
if(moveVector[1] > 0 && moveVector[0] < 0)
return 22;
if(moveVector[1] > 0 && moveVector[0] == 0)
return -45;
return -22;
}
开发者ID:icanhas,项目名称:yantar,代码行数:33,代码来源:players.c
示例4: GLimp_CompareModes
/**
* @brief GLimp_CompareModes
* @param[in] a
* @param[in] b
* @return
*/
static int GLimp_CompareModes(const void *a, const void *b)
{
const float ASPECT_EPSILON = 0.001f;
const SDL_Rect *modeA = (const SDL_Rect *)a;
const SDL_Rect *modeB = (const SDL_Rect *)b;
float aspectA = modeA->w / (float)modeA->h;
float aspectB = modeB->w / (float)modeB->h;
int areaA = modeA->w * modeA->h;
int areaB = modeB->w * modeB->h;
float aspectDiffA = Q_fabs(aspectA - displayAspect);
float aspectDiffB = Q_fabs(aspectB - displayAspect);
float aspectDiffsDiff = aspectDiffA - aspectDiffB;
if (aspectDiffsDiff > ASPECT_EPSILON)
{
return 1;
}
else if (aspectDiffsDiff < -ASPECT_EPSILON)
{
return -1;
}
else
{
return areaA - areaB;
}
}
开发者ID:zturtleman,项目名称:etlegacy,代码行数:32,代码来源:sdl_glimp.c
示例5: TrackTarget
void CFuncTank::__MAKE_VHOOK(Think)()
{
pev->avelocity = g_vecZero;
TrackTarget();
if (Q_fabs(float_precision(pev->avelocity.x)) > 1 || Q_fabs(float_precision(pev->avelocity.y)) > 1)
StartRotSound();
else
StopRotSound();
}
开发者ID:Solexid,项目名称:ReGameDLL_CS,代码行数:10,代码来源:func_tank.cpp
示例6: UI_MovedirAdjustment
/*
======================
UI_MovedirAdjustment
======================
*/
static float UI_MovedirAdjustment( playerInfo_t *pi )
{
vec3_t relativeAngles;
vec3_t moveVector;
VectorSubtract( pi->viewAngles, pi->moveAngles, relativeAngles );
AngleVectors( relativeAngles, moveVector, NULL, NULL );
if ( Q_fabs( moveVector[ 0 ] ) < 0.01 )
{
moveVector[ 0 ] = 0.0;
}
if ( Q_fabs( moveVector[ 1 ] ) < 0.01 )
{
moveVector[ 1 ] = 0.0;
}
if ( moveVector[ 1 ] == 0 && moveVector[ 0 ] > 0 )
{
return 0;
}
if ( moveVector[ 1 ] < 0 && moveVector[ 0 ] > 0 )
{
return 22;
}
if ( moveVector[ 1 ] < 0 && moveVector[ 0 ] == 0 )
{
return 45;
}
if ( moveVector[ 1 ] < 0 && moveVector[ 0 ] < 0 )
{
return -22;
}
if ( moveVector[ 1 ] == 0 && moveVector[ 0 ] < 0 )
{
return 0;
}
if ( moveVector[ 1 ] > 0 && moveVector[ 0 ] < 0 )
{
return 22;
}
if ( moveVector[ 1 ] > 0 && moveVector[ 0 ] == 0 )
{
return -45;
}
return -22;
}
开发者ID:SHOVELL,项目名称:Unvanquished,代码行数:60,代码来源:ui_players.c
示例7: RadiusFromBounds
float RadiusFromBounds( const vector3 *mins, const vector3 *maxs ) {
int i;
vector3 corner;
float a, b;
for ( i = 0; i<3; i++ ) {
a = Q_fabs( mins->raw[i] );
b = Q_fabs( maxs->raw[i] );
corner.raw[i] = a > b ? a : b;
}
return VectorLength( &corner );
}
开发者ID:Arcadiaprime,项目名称:japp,代码行数:13,代码来源:q_math.cpp
示例8: CM_PlaneEqual
/*
==================
CM_PlaneEqual
==================
*/
int CM_PlaneEqual( patchPlane_t *p, float plane[4], int *flipped ) {
float invplane[4];
if (
Q_fabs( p->plane[0] - plane[0] ) < NORMAL_EPSILON
&& Q_fabs( p->plane[1] - plane[1] ) < NORMAL_EPSILON
&& Q_fabs( p->plane[2] - plane[2] ) < NORMAL_EPSILON
&& Q_fabs( p->plane[3] - plane[3] ) < DIST_EPSILON ) {
*flipped = qfalse;
return qtrue;
}
VectorNegate( plane, invplane );
invplane[3] = -plane[3];
if (
Q_fabs( p->plane[0] - invplane[0] ) < NORMAL_EPSILON
&& Q_fabs( p->plane[1] - invplane[1] ) < NORMAL_EPSILON
&& Q_fabs( p->plane[2] - invplane[2] ) < NORMAL_EPSILON
&& Q_fabs( p->plane[3] - invplane[3] ) < DIST_EPSILON ) {
*flipped = qtrue;
return qtrue;
}
return qfalse;
}
开发者ID:AdrienJaguenet,项目名称:Enemy-Territory,代码行数:31,代码来源:cm_patch.c
示例9: RadiusFromBounds
/*
=================
RadiusFromBounds
=================
*/
vec_t RadiusFromBounds (const vec3_t mins, const vec3_t maxs) {
int i;
vec3_t corner;
vec_t a, b;
for (i=0 ; i<3 ; i++)
{
a = Q_fabs(mins[i]);
b = Q_fabs(maxs[i]);
corner[i] = a > b ? a : b;
}
return VectorLength (corner);
}
开发者ID:Bad-ptr,项目名称:q2pro,代码行数:19,代码来源:q_shared.c
示例10: CL_MouseClamp
void CL_MouseClamp(int *x, int *y)
{
float ax = Q_fabs(*x);
float ay = Q_fabs(*y);
ax = (ax-10)*(3.0f/45.0f) * (ax-10) * (Q_fabs(*x) > 10);
ay = (ay-10)*(3.0f/45.0f) * (ay-10) * (Q_fabs(*y) > 10);
if (*x < 0)
*x = -ax;
else
*x = ax;
if (*y < 0)
*y = -ay;
else
*y = ay;
}
开发者ID:AlexCSilva,项目名称:jediacademy,代码行数:16,代码来源:cl_input.cpp
示例11: GetFeet
bool CHostageImprov::FaceTowards(const Vector &target, float deltaT)
{
bool bError = false;
Vector2D to = (target - GetFeet()).Make2D();
#ifndef PLAY_GAMEDLL
to.NormalizeInPlace();
#else
// TODO: fix test demo
float_precision float_x = target.x - GetFeet().x;
float_precision float_y = target.y - GetFeet().y;
float_precision flLen = to.Length();
if (flLen <= 0)
{
to.x = 1;
to.y = 0;
}
else
{
to.x = float_x / flLen;
to.y = float_y / flLen;
}
#endif
float moveAngle = GetMoveAngle();
Vector2D lat(BotCOS(moveAngle), BotSIN(moveAngle));
Vector2D dir(-lat.y, lat.x);
float_precision dot = DotProduct(to, dir);
if (DotProduct(to, lat) < 0.0f)
{
if (dot >= 0.0f)
dot = 1.0f;
else
dot = -1.0f;
bError = true;
}
const float maxTurnRate = 0.05f;
if (bError || Q_fabs(dot) >= maxTurnRate)
{
const float tolerance = 300.0f;
float moveRatio = dot * deltaT * tolerance + moveAngle;
BotCOS(moveRatio);
BotSIN(moveRatio);
m_moveAngle = moveRatio;
m_hostage->pev->angles.y = moveRatio;
return false;
}
return true;
}
开发者ID:Solexid,项目名称:ReGameDLL_CS,代码行数:60,代码来源:hostage_improv.cpp
示例12: Vector
void CGib::BounceGibTouch(CBaseEntity *pOther)
{
if (pev->flags & FL_ONGROUND)
{
pev->velocity = pev->velocity * 0.9;
pev->angles.x = 0;
pev->angles.z = 0;
pev->avelocity.x = 0;
pev->avelocity.z = 0;
}
else
{
if (g_Language != LANGUAGE_GERMAN && m_cBloodDecals > 0 && m_bloodColor != DONT_BLEED)
{
TraceResult tr;
Vector vecSpot = pev->origin + Vector(0, 0, 8);
UTIL_TraceLine(vecSpot, vecSpot + Vector(0, 0, -24), ignore_monsters, ENT(pev), &tr);
UTIL_BloodDecalTrace(&tr, m_bloodColor);
m_cBloodDecals--;
}
if (m_material != matNone && !RANDOM_LONG(0, 2))
{
float zvel = Q_fabs(pev->velocity.z);
float volume = 0.8 * Q_min(1.0f, zvel / 450);
CBreakable::MaterialSoundRandom(edict(), (Materials)m_material, volume);
}
}
}
开发者ID:a1batross,项目名称:ReGameDLL_CS,代码行数:30,代码来源:combat.cpp
示例13: CG_LimboPanel_RenderCounter_RollTimeForButton
int CG_LimboPanel_RenderCounter_RollTimeForButton(panel_button_t *button) {
float diff;
switch (button->data[0]) {
case 0: // class counts
case 1: // team counts
return 100.f;
case 4: // skills
return 1000.f;
case 6: // stats
diff = Q_fabs(button->data[3] - CG_LimboPanel_RenderCounter_ValueForButton(button));
if (diff < 5) {
return 200.f / diff;
}
return 50.f;
case 5: // clock
case 3: // respawn time
case 2: // xp
return 50.f;
}
return 1000.f;
}
开发者ID:ETrun,项目名称:ETrun,代码行数:26,代码来源:cg_limbopanel.c
示例14: CM_CalcTraceBounds
/*
================
CM_CalcTraceBounds
================
*/
static void CM_CalcTraceBounds(traceWork_t *tw, qboolean expand)
{
int i;
if (tw->sphere.use)
{
for (i = 0; i < 3; i++)
{
if (tw->start[i] < tw->end[i])
{
tw->bounds[0][i] = tw->start[i] - Q_fabs(tw->sphere.offset[i]) - tw->sphere.radius;
tw->bounds[1][i] = tw->start[i] + tw->trace.fraction * tw->dir[i] + Q_fabs(tw->sphere.offset[i]) + tw->sphere.radius;
}
else
{
tw->bounds[0][i] = tw->start[i] + tw->trace.fraction * tw->dir[i] - Q_fabs(tw->sphere.offset[i]) - tw->sphere.radius;
tw->bounds[1][i] = tw->start[i] + Q_fabs(tw->sphere.offset[i]) + tw->sphere.radius;
}
}
}
else
{
for (i = 0; i < 3; i++)
{
if (tw->start[i] < tw->end[i])
{
tw->bounds[0][i] = tw->start[i] + tw->size[0][i];
tw->bounds[1][i] = tw->start[i] + tw->trace.fraction * tw->dir[i] + tw->size[1][i];
}
else
{
tw->bounds[0][i] = tw->start[i] + tw->trace.fraction * tw->dir[i] + tw->size[0][i];
tw->bounds[1][i] = tw->start[i] + tw->size[1][i];
}
}
}
if (expand)
{
// expand for epsilon
for (i = 0; i < 3; i++)
{
tw->bounds[0][i] -= 1.0f;
tw->bounds[1][i] += 1.0f;
}
}
}
开发者ID:belstgut,项目名称:etlegacy,代码行数:52,代码来源:cm_trace.c
示例15: CM_SnapVector
/*
==================
CM_SnapVector
==================
*/
void CM_SnapVector( vec3_t normal ) {
int i;
for ( i = 0 ; i < 3 ; i++ )
{
if ( Q_fabs( normal[i] - 1 ) < NORMAL_EPSILON ) {
VectorClear( normal );
normal[i] = 1;
break;
}
if ( Q_fabs( normal[i] - -1 ) < NORMAL_EPSILON ) {
VectorClear( normal );
normal[i] = -1;
break;
}
}
}
开发者ID:AdrienJaguenet,项目名称:Enemy-Territory,代码行数:22,代码来源:cm_patch.c
示例16: Q_fabs
/*
=======================================================================================================================================
BaseWindingForPlane
=======================================================================================================================================
*/
winding_t *BaseWindingForPlane(vec3_t normal, vec_t dist) {
int i, x = -1;
vec_t max = -MAX_MAP_BOUNDS, v;
vec3_t org, vright, vup;
winding_t *w;
// find the major axis
for (i = 0; i < 3; i++) {
v = Q_fabs(normal[i]);
if (v > max) {
x = i;
max = v;
}
}
if (x == -1) {
Com_Error(ERR_DROP, "BaseWindingForPlane: no axis found");
}
VectorCopy(vec3_origin, vup);
switch (x) {
case 0:
case 1:
vup[2] = 1;
break;
case 2:
vup[0] = 1;
break;
}
v = DotProduct(vup, normal);
VectorMA(vup, -v, normal, vup);
vec3_norm2(vup, vup);
VectorScale(normal, dist, org);
vec3_cross(vup, normal, vright);
VectorScale(vup, MAX_MAP_BOUNDS, vup);
VectorScale(vright, MAX_MAP_BOUNDS, vright);
// project a really big axis aligned box onto the plane
w = AllocWinding(4);
VectorSubtract(org, vright, w->p[0]);
VectorAdd(w->p[0], vup, w->p[0]);
VectorAdd(org, vright, w->p[1]);
VectorAdd(w->p[1], vup, w->p[1]);
VectorAdd(org, vright, w->p[2]);
VectorSubtract(w->p[2], vup, w->p[2]);
VectorSubtract(org, vright, w->p[3]);
VectorSubtract(w->p[3], vup, w->p[3]);
w->numpoints = 4;
return w;
}
开发者ID:ioid3-games,项目名称:ioid3-wet,代码行数:61,代码来源:cm_polylib.c
示例17: UI_MovedirAdjustment
static float UI_MovedirAdjustment( playerInfo_t *pi ) {
vector3 relativeAngles;
vector3 moveVector;
VectorSubtract( &pi->viewAngles, &pi->moveAngles, &relativeAngles );
AngleVectors( &relativeAngles, &moveVector, NULL, NULL );
if ( Q_fabs( moveVector.x ) < 0.01f ) moveVector.x = 0.0f;
if ( Q_fabs( moveVector.y ) < 0.01f ) moveVector.y = 0.0f;
if ( moveVector.y == 0 && moveVector.x > 0 ) return 0;
if ( moveVector.y < 0 && moveVector.x > 0 ) return 22;
if ( moveVector.y < 0 && moveVector.x == 0 ) return 45;
if ( moveVector.y < 0 && moveVector.x < 0 ) return -22;
if ( moveVector.y == 0 && moveVector.x < 0 ) return 0;
if ( moveVector.y > 0 && moveVector.x < 0 ) return 22;
if ( moveVector.y > 0 && moveVector.x == 0 ) return -45;
return -22;
}
开发者ID:Razish,项目名称:QtZ,代码行数:19,代码来源:ui_players.c
示例18: CM_BoxDistanceFromPlane
/*
================
CM_BoxDistanceFromPlane
================
*/
static float CM_BoxDistanceFromPlane(vec3_t center, vec3_t extents, cplane_t *plane)
{
float d1, d2;
d1 = DotProduct(center, plane->normal) - plane->dist;
d2 = Q_fabs(extents[0] * plane->normal[0]) +
Q_fabs(extents[1] * plane->normal[1]) +
Q_fabs(extents[2] * plane->normal[2]);
if (d1 - d2 > 0.0f)
{
return d1 - d2;
}
if (d1 + d2 < 0.0f)
{
return d1 + d2;
}
return 0.0f;
}
开发者ID:belstgut,项目名称:etlegacy,代码行数:24,代码来源:cm_trace.c
示例19: BotDirectionToUsercmd
void BotDirectionToUsercmd( gentity_t *self, vec3_t dir, usercmd_t *cmd )
{
vec3_t forward;
vec3_t right;
float forwardmove;
float rightmove;
signed char speed = BotGetMaxMoveSpeed( self );
AngleVectors( self->client->ps.viewangles, forward, right, nullptr );
forward[2] = 0;
VectorNormalize( forward );
right[2] = 0;
VectorNormalize( right );
// get direction and non-optimal magnitude
forwardmove = speed * DotProduct( forward, dir );
rightmove = speed * DotProduct( right, dir );
// find optimal magnitude to make speed as high as possible
if ( Q_fabs( forwardmove ) > Q_fabs( rightmove ) )
{
float highestforward = forwardmove < 0 ? -speed : speed;
float highestright = highestforward * rightmove / forwardmove;
cmd->forwardmove = ClampChar( highestforward );
cmd->rightmove = ClampChar( highestright );
}
else
{
float highestright = rightmove < 0 ? -speed : speed;
float highestforward = highestright * forwardmove / rightmove;
cmd->forwardmove = ClampChar( highestforward );
cmd->rightmove = ClampChar( highestright );
}
}
开发者ID:ChunHungLiu,项目名称:Unvanquished,代码行数:39,代码来源:sg_bot_nav.cpp
示例20: FX_ProbeBeam
//TiM - Beam FX for the Neutrino Probe weapon
void FX_ProbeBeam( vec3_t origin, vec3_t dir, int clientNum, qboolean alt_fire )
{
trace_t tr;
refEntity_t beam;
vec3_t end;
float scale;
memset( &beam, 0, sizeof( beam ) );
if ( alt_fire )
scale = flrandom(7.0f, 12.0f);
else
scale = Q_fabs( 12.0f * sin( cg.time * 0.1f ) );
VectorMA( origin, PROBE_BEAM_LENGTH, dir, end );
CG_Trace( &tr, origin, NULL, NULL, end, clientNum, CONTENTS_SOLID );
trap_R_AddLightToScene( origin, 20, 114.0f / 255, 164.0f / 255, 1.0f );
VectorCopy( origin, beam.origin);
VectorCopy( tr.endpos, beam.oldorigin );
beam.reType = RT_LINE;
beam.customShader = cgs.media.probeBeam;
beam.shaderRGBA[0] = 0xff;
beam.shaderRGBA[1] = 0xff;
beam.shaderRGBA[2] = 0xff;
beam.shaderRGBA[3] = 0xff;
AxisClear( beam.axis );
beam.data.line.width = scale*0.1;
beam.data.line.width2 = scale;
beam.data.line.stscale = 1.0;
trap_R_AddRefEntityToScene( &beam );
if ( tr.fraction != 1.0f )
{
float radius;
if ( alt_fire )
radius = flrandom(1.5f, 3.0f) * (1.0 - (tr.fraction*0.3));
else
radius = flrandom(0.5f, 1.5f) * (1.0 - (tr.fraction*0.3));
if ( !radius )
return;
CG_ImpactMark( cgs.media.probeDecal, tr.endpos, tr.plane.normal, 0, 1, 1, 1, 0.2*(1.0-tr.fraction), qfalse, radius, qtrue );
trap_R_AddLightToScene( origin, radius*5, 114.0f / 255, 164.0f / 255, 1.0f );
}
}
开发者ID:UberGames,项目名称:RPG-X2-rpgxEF,代码行数:52,代码来源:fx_misc.c
注:本文中的Q_fabs函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论