当前位置: 首页>>代码示例>>C++>>正文


C++ Q_fabs函数代码示例

本文整理汇总了C++中Q_fabs函数的典型用法代码示例。如果您正苦于以下问题:C++ Q_fabs函数的具体用法?C++ Q_fabs怎么用?C++ Q_fabs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Q_fabs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的Q_fabs函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。