本文整理汇总了C++中FixedMul函数的典型用法代码示例。如果您正苦于以下问题:C++ FixedMul函数的具体用法?C++ FixedMul怎么用?C++ FixedMul使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FixedMul函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: A_Tracer2
void A_Tracer2 (AActor *self)
{
AActor *dest;
angle_t exact;
fixed_t dist;
fixed_t slope;
dest = self->tracer;
if (dest == NULL || dest->health <= 0 || self->Speed == 0)
return;
// change angle
exact = R_PointToAngle2 (self->x, self->y, dest->x, dest->y);
if (exact != self->angle)
{
if (exact - self->angle > 0x80000000)
{
self->angle -= TRACEANGLE;
if (exact - self->angle < 0x80000000)
self->angle = exact;
}
else
{
self->angle += TRACEANGLE;
if (exact - self->angle > 0x80000000)
self->angle = exact;
}
}
exact = self->angle >> ANGLETOFINESHIFT;
self->momx = FixedMul (self->Speed, finecosine[exact]);
self->momy = FixedMul (self->Speed, finesine[exact]);
// change slope
dist = P_AproxDistance (dest->x - self->x, dest->y - self->y);
dist /= self->Speed;
if (dist < 1)
{
dist = 1;
}
if (dest->height >= 56*FRACUNIT)
{
slope = (dest->z+40*FRACUNIT - self->z) / dist;
}
else
{
slope = (dest->z + self->height*2/3 - self->z) / dist;
}
if (slope < self->momz)
{
self->momz -= FRACUNIT/8;
}
else
{
self->momz += FRACUNIT/8;
}
}
示例2: TPS
//=============================================================================
static void HW3S_FillSourceParameters
(const mobj_t *origin,
source3D_data_t *data,
channel_type_t c_type)
{
fixed_t x = 0, y = 0, z = 0;
data->max_distance = MAX_DISTANCE;
data->min_distance = MIN_DISTANCE;
if (origin && origin != players[displayplayer].mo)
{
data->head_relative = false;
data->pos.momx = TPS(FIXED_TO_FLOAT(origin->momx));
data->pos.momy = TPS(FIXED_TO_FLOAT(origin->momy));
data->pos.momz = TPS(FIXED_TO_FLOAT(origin->momz));
x = origin->x;
y = origin->y;
z = origin->z;
if (c_type == CT_ATTACK)
{
const angle_t an = origin->angle >> ANGLETOFINESHIFT;
x += FixedMul(16*FRACUNIT, FINECOSINE(an));
y += FixedMul(16*FRACUNIT, FINESINE(an));
z += origin->height >> 1;
}
else if (c_type == CT_SCREAM)
示例3: DEFINE_ACTION_FUNCTION
DEFINE_ACTION_FUNCTION(AActor, A_InquisitorJump)
{
fixed_t dist;
fixed_t speed;
angle_t an;
if (self->target == NULL)
return;
S_Sound (self, CHAN_ITEM|CHAN_LOOP, "inquisitor/jump", 1, ATTN_NORM);
self->AddZ(64*FRACUNIT);
A_FaceTarget (self);
an = self->angle >> ANGLETOFINESHIFT;
speed = self->Speed * 2/3;
self->velx += FixedMul (speed, finecosine[an]);
self->vely += FixedMul (speed, finesine[an]);
dist = self->AproxDistance (self->target);
dist /= speed;
if (dist < 1)
{
dist = 1;
}
self->velz = (self->target->Z() - self->Z()) / dist;
self->reactiontime = 60;
self->flags |= MF_NOGRAVITY;
}
示例4: P_GetZAt
//
// P_GetZAt
//
// Returns the height of the sloped plane at (x, y) as a fixed_t
//
fixed_t P_GetZAt(pslope_t *slope, fixed_t x, fixed_t y)
{
fixed_t dist = FixedMul(x - slope->o.x, slope->d.x) +
FixedMul(y - slope->o.y, slope->d.y);
return slope->o.z + FixedMul(dist, slope->zdelta);
}
示例5: PTR_chaseTraverse
//
// PTR_chaseTraverse
//
// go til you hit a wall
// set the chasecam target x and ys if you hit one
// originally based on the shooting traverse function in p_maputl.c
//
static bool PTR_chaseTraverse(intercept_t *in)
{
fixed_t dist, frac;
subsector_t *ss;
int x, y;
int z;
sector_t *othersector;
if(in->isaline)
{
line_t *li = in->d.line;
dist = FixedMul(trace.attackrange, in->frac);
frac = in->frac - FixedDiv(12*FRACUNIT, trace.attackrange);
// hit line
// position a bit closer
x = trace.dl.x + FixedMul(trace.dl.dx, frac);
y = trace.dl.y + FixedMul(trace.dl.dy, frac);
// ioanch 20160225: portal lines are currently not crossed
if(li->flags & ML_TWOSIDED && !(li->pflags & PS_PASSABLE))
{ // crosses a two sided line
// sf: find which side it hit
ss = R_PointInSubsector (x, y);
othersector = li->backsector;
if(ss->sector==li->backsector) // other side
othersector = li->frontsector;
// interpolate, find z at the point of intersection
z = zi(dist, trace.attackrange, targetz, playermobj->z+28*FRACUNIT);
// found which side, check for intersections
if((li->flags & ML_BLOCKING) ||
(othersector->floorheight>z) || (othersector->ceilingheight<z)
|| (othersector->ceilingheight-othersector->floorheight
< 40*FRACUNIT)); // hit
else
{
return true; // continue
}
}
targetx = x; // point the new chasecam target at the intersection
targety = y;
targetz = zi(dist, trace.attackrange, targetz, playermobj->z+28*FRACUNIT);
// don't go any farther
return false;
}
return true;
}
示例6: FV_Magnitude
fixed_t FV_Magnitude(const vector_t *a_normal)
{
INT32 xs = FixedMul(a_normal->x,a_normal->x);
INT32 ys = FixedMul(a_normal->y,a_normal->y);
INT32 zs = FixedMul(a_normal->z,a_normal->z);
return FixedSqrt(xs+ys+zs);
}
示例7: FM_CreateObjectMatrix
//
// CreateObjectMatrix
//
// Creates a matrix that can be used for
// adjusting the position of an object
//
void FM_CreateObjectMatrix(matrix_t *matrix, fixed_t x, fixed_t y, fixed_t z, fixed_t anglex, fixed_t angley, fixed_t anglez, fixed_t upx, fixed_t upy, fixed_t upz, fixed_t radius)
{
vector_t upcross;
vector_t upvec;
vector_t basevec;
FV_Load(&upvec, upx, upy, upz);
FV_Load(&basevec, anglex, angley, anglez);
FV_Cross(&upvec, &basevec, &upcross);
FV_Normalize(&upcross);
FM_LoadIdentity(matrix);
matrix->m[0] = upcross.x;
matrix->m[1] = upcross.y;
matrix->m[2] = upcross.z;
matrix->m[3] = 0*FRACUNIT;
matrix->m[4] = upx;
matrix->m[5] = upy;
matrix->m[6] = upz;
matrix->m[7] = 0;
matrix->m[8] = anglex;
matrix->m[9] = angley;
matrix->m[10] = anglez;
matrix->m[11] = 0;
matrix->m[12] = x - FixedMul(upx,radius);
matrix->m[13] = y - FixedMul(upy,radius);
matrix->m[14] = z - FixedMul(upz,radius);
matrix->m[15] = FRACUNIT;
}
示例8: FixedMul
vector_t *FV_MulEx(const vector_t *a_i, fixed_t a_c, vector_t *a_o)
{
a_o->x = FixedMul(a_i->x, a_c);
a_o->y = FixedMul(a_i->y, a_c);
a_o->z = FixedMul(a_i->z, a_c);
return a_o;
}
示例9: FV_Distance
fixed_t FV_Distance(const vector_t *p1, const vector_t *p2)
{
INT32 xs = FixedMul(p2->x-p1->x,p2->x-p1->x);
INT32 ys = FixedMul(p2->y-p1->y,p2->y-p1->y);
INT32 zs = FixedMul(p2->z-p1->z,p2->z-p1->z);
return FixedSqrt(xs+ys+zs);
}
示例10: FixedHypot
fixed_t FixedHypot(fixed_t x, fixed_t y)
{
#ifdef HAVE_HYPOT
const float fx = FIXED_TO_FLOAT(x);
const float fy = FIXED_TO_FLOAT(y);
float fz;
#ifdef HAVE_HYPOTF
fz = hypotf(fx, fy);
#else
fz = (float)hypot(fx, fy);
#endif
return FLOAT_TO_FIXED(fz);
#else // !HAVE_HYPOT
fixed_t ax, yx, yx2, yx1;
if (abs(y) > abs(x)) // |y|>|x|
{
ax = abs(y); // |y| => ax
yx = FixedDiv(x, y); // (x/y)
}
else // |x|>|y|
{
ax = abs(x); // |x| => ax
yx = FixedDiv(y, x); // (x/y)
}
yx2 = FixedMul(yx, yx); // (x/y)^2
yx1 = FixedSqrt(1+FRACUNIT + yx2); // (1 + (x/y)^2)^1/2
return FixedMul(ax, yx1); // |x|*((1 + (x/y)^2)^1/2)
#endif
}
示例11: CTF_MoveFlags
//
// [Toke - CTF] CTF_MoveFlag
// Moves the flag that is linked to a player
//
void CTF_MoveFlags ()
{
// denis - flag is now a boolean
for(size_t i = 0; i < NUMFLAGS; i++)
{
if(CTFdata[i].flagger && CTFdata[i].actor)
{
player_t &player = idplayer(CTFdata[i].flagger);
AActor *flag = CTFdata[i].actor;
if(!player.mo)
{
flag->UnlinkFromWorld ();
return;
}
extern fixed_t tmfloorz;
extern fixed_t tmceilingz;
unsigned an = player.mo->angle >> ANGLETOFINESHIFT;
fixed_t x = (player.mo->x + FixedMul (-2*FRACUNIT, finecosine[an]));
fixed_t y = (player.mo->y + FixedMul (-2*FRACUNIT, finesine[an]));
P_CheckPosition (player.mo, player.mo->x, player.mo->y);
flag->UnlinkFromWorld ();
flag->x = x;
flag->y = y;
flag->z = player.mo->z;
flag->floorz = tmfloorz;
flag->ceilingz = tmceilingz;
flag->LinkToWorld ();
}
}
示例12: A_VolcBallImpact
void A_VolcBallImpact (AActor *ball)
{
int i;
AActor *tiny;
angle_t angle;
if (ball->z <= ball->floorz)
{
ball->flags |= MF_NOGRAVITY;
ball->gravity = FRACUNIT;
ball->z += 28*FRACUNIT;
//ball->momz = 3*FRACUNIT;
}
P_RadiusAttack (ball, ball->target, 25, 25, NAME_Fire, true);
for (i = 0; i < 4; i++)
{
tiny = Spawn<AVolcanoTBlast> (ball->x, ball->y, ball->z, ALLOW_REPLACE);
tiny->target = ball;
angle = i*ANG90;
tiny->angle = angle;
angle >>= ANGLETOFINESHIFT;
tiny->momx = FixedMul (FRACUNIT*7/10, finecosine[angle]);
tiny->momy = FixedMul (FRACUNIT*7/10, finesine[angle]);
tiny->momz = FRACUNIT + (pr_impact() << 9);
P_CheckMissileSpawn (tiny);
}
}
示例13: DEFINE_ACTION_FUNCTION
DEFINE_ACTION_FUNCTION(AActor, A_VolcBallImpact)
{
unsigned int i;
AActor *tiny;
angle_t angle;
if (self->z <= self->floorz)
{
self->flags |= MF_NOGRAVITY;
self->gravity = FRACUNIT;
self->z += 28*FRACUNIT;
//self->velz = 3*FRACUNIT;
}
P_RadiusAttack (self, self->target, 25, 25, NAME_Fire, RADF_HURTSOURCE);
for (i = 0; i < 4; i++)
{
tiny = Spawn("VolcanoTBlast", self->x, self->y, self->z, ALLOW_REPLACE);
tiny->target = self;
angle = i*ANG90;
tiny->angle = angle;
angle >>= ANGLETOFINESHIFT;
tiny->velx = FixedMul (FRACUNIT*7/10, finecosine[angle]);
tiny->vely = FixedMul (FRACUNIT*7/10, finesine[angle]);
tiny->velz = FRACUNIT + (pr_volcimpact() << 9);
P_CheckMissileSpawn (tiny, self->radius);
}
}
示例14: EV_BuildPillar
int EV_BuildPillar(line_t *line, byte *args, boolean crush)
{
int secnum;
sector_t *sec;
pillar_t *pillar;
int newHeight;
int rtn;
rtn = 0;
secnum = -1;
while((secnum = P_FindSectorFromTag(args[0], secnum)) >= 0)
{
sec = §ors[secnum];
if(sec->specialdata)
continue; // already moving
if(sec->floorheight == sec->ceilingheight)
{ // pillar is already closed
continue;
}
rtn = 1;
if(!args[2])
{
newHeight = sec->floorheight+
((sec->ceilingheight-sec->floorheight)/2);
}
else
{
newHeight = sec->floorheight+(args[2]<<FRACBITS);
}
pillar = Z_Malloc(sizeof(*pillar), PU_LEVSPEC, 0);
sec->specialdata = pillar;
P_AddThinker(&pillar->thinker);
pillar->thinker.function = T_BuildPillar;
pillar->sector = sec;
if(!args[2])
{
pillar->ceilingSpeed = pillar->floorSpeed = args[1]*(FRACUNIT/8);
}
else if(newHeight-sec->floorheight > sec->ceilingheight-newHeight)
{
pillar->floorSpeed = args[1]*(FRACUNIT/8);
pillar->ceilingSpeed = FixedMul(sec->ceilingheight-newHeight,
FixedDiv(pillar->floorSpeed, newHeight-sec->floorheight));
}
else
{
pillar->ceilingSpeed = args[1]*(FRACUNIT/8);
pillar->floorSpeed = FixedMul(newHeight-sec->floorheight,
FixedDiv(pillar->ceilingSpeed, sec->ceilingheight-newHeight));
}
pillar->floordest = newHeight;
pillar->ceilingdest = newHeight;
pillar->direction = 1;
pillar->crush = crush*args[3];
SN_StartSequence((mobj_t *)&pillar->sector->soundorg,
SEQ_PLATFORM+pillar->sector->seqType);
}
return rtn;
}
示例15: A_ImpMsAttack
void A_ImpMsAttack (AActor *self)
{
AActor *dest;
angle_t an;
int dist;
if (!self->target || pr_impmsatk() > 64)
{
self->SetState (self->SeeState);
return;
}
dest = self->target;
self->flags |= MF_SKULLFLY;
S_SoundID (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
A_FaceTarget (self);
an = self->angle >> ANGLETOFINESHIFT;
self->momx = FixedMul (12*FRACUNIT, finecosine[an]);
self->momy = FixedMul (12*FRACUNIT, finesine[an]);
dist = P_AproxDistance (dest->x - self->x, dest->y - self->y);
dist = dist/(12*FRACUNIT);
if (dist < 1)
{
dist = 1;
}
self->momz = (dest->z + (dest->height>>1) - self->z)/dist;
}