本文整理汇总了C++中VectorCompare函数的典型用法代码示例。如果您正苦于以下问题:C++ VectorCompare函数的具体用法?C++ VectorCompare怎么用?C++ VectorCompare使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VectorCompare函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: R_DrawSkyportal
/*
* R_DrawSkyportal
*/
static void R_DrawSkyportal( const entity_t *e, skyportal_t *skyportal ) {
if( !R_PushRefInst() ) {
return;
}
rn.renderFlags = ( rn.renderFlags | RF_PORTALVIEW );
//rn.renderFlags &= ~RF_SOFT_PARTICLES;
VectorCopy( skyportal->vieworg, rn.pvsOrigin );
rn.nearClip = Z_NEAR;
rn.farClip = R_DefaultFarClip();
rn.polygonFactor = POLYOFFSET_FACTOR;
rn.polygonUnits = POLYOFFSET_UNITS;
rn.clipFlags = 15;
rn.meshlist = &r_skyportallist;
rn.portalmasklist = NULL;
rn.rtLight = NULL;
//Vector4Set( rn.scissor, rn.refdef.x + x, rn.refdef.y + y, w, h );
if( skyportal->noEnts ) {
rn.renderFlags |= RF_ENVVIEW;
}
if( skyportal->scale ) {
vec3_t centre, diff;
VectorAdd( rsh.worldModel->mins, rsh.worldModel->maxs, centre );
VectorScale( centre, 0.5f, centre );
VectorSubtract( centre, rn.viewOrigin, diff );
VectorMA( skyportal->vieworg, -skyportal->scale, diff, rn.refdef.vieworg );
} else {
VectorCopy( skyportal->vieworg, rn.refdef.vieworg );
}
// FIXME
if( !VectorCompare( skyportal->viewanglesOffset, vec3_origin ) ) {
vec3_t angles;
mat3_t axis;
Matrix3_Copy( rn.refdef.viewaxis, axis );
VectorInverse( &axis[AXIS_RIGHT] );
Matrix3_ToAngles( axis, angles );
VectorAdd( angles, skyportal->viewanglesOffset, angles );
AnglesToAxis( angles, axis );
Matrix3_Copy( axis, rn.refdef.viewaxis );
}
rn.refdef.rdflags &= ~( RDF_UNDERWATER | RDF_CROSSINGWATER | RDF_SKYPORTALINVIEW );
if( skyportal->fov ) {
rn.refdef.fov_y = WidescreenFov( skyportal->fov );
rn.refdef.fov_x = CalcHorizontalFov( rn.refdef.fov_y, rn.refdef.width, rn.refdef.height );
}
R_SetupViewMatrices( &rn.refdef );
R_SetupFrustum( &rn.refdef, rn.nearClip, rn.farClip, rn.frustum, rn.frustumCorners );
R_SetupPVS( &rn.refdef );
R_RenderView( &rn.refdef );
// restore modelview and projection matrices, scissoring, etc for the main view
R_PopRefInst();
}
示例2: RB_CalcDeformVertexes
/*
========================
RB_CalcDeformVertexes
========================
*/
void RB_CalcDeformVertexes( deformStage_t *ds ) {
int i;
vec3_t offset;
float scale;
float *xyz = ( float * ) tess.xyz;
float *normal = ( float * ) tess.normal;
float *table;
// Ridah
if ( ds->deformationWave.frequency < 0 ) {
qboolean inverse = qfalse;
vec3_t worldUp;
//static vec3_t up = {0,0,1};
if ( VectorCompare( backEnd.currentEntity->e.fireRiseDir, vec3_origin ) ) {
VectorSet( backEnd.currentEntity->e.fireRiseDir, 0, 0, 1 );
}
// get the world up vector in local coordinates
if ( backEnd.currentEntity->e.hModel ) { // world surfaces dont have an axis
VectorRotate( backEnd.currentEntity->e.fireRiseDir, backEnd.currentEntity->e.axis, worldUp );
} else {
VectorCopy( backEnd.currentEntity->e.fireRiseDir, worldUp );
}
// don't go so far if sideways, since they must be moving
VectorScale( worldUp, 0.4 + 0.6 * fabs( backEnd.currentEntity->e.fireRiseDir[2] ), worldUp );
ds->deformationWave.frequency *= -1;
if ( ds->deformationWave.frequency > 999 ) { // hack for negative Z deformation (ack)
inverse = qtrue;
ds->deformationWave.frequency -= 999;
}
table = TableForFunc( ds->deformationWave.func );
for ( i = 0; i < tess.numVertexes; i++, xyz += 4, normal += 4 )
{
float off = ( xyz[0] + xyz[1] + xyz[2] ) * ds->deformationSpread;
float dot;
scale = WAVEVALUE( table, ds->deformationWave.base,
ds->deformationWave.amplitude,
ds->deformationWave.phase + off,
ds->deformationWave.frequency );
dot = DotProduct( worldUp, normal );
if ( dot * scale > 0 ) {
if ( inverse ) {
scale *= -1;
}
VectorMA( xyz, dot * scale, worldUp, xyz );
}
}
if ( inverse ) {
ds->deformationWave.frequency += 999;
}
ds->deformationWave.frequency *= -1;
}
// done.
else if ( ds->deformationWave.frequency == 0 ) {
scale = EvalWaveForm( &ds->deformationWave );
for ( i = 0; i < tess.numVertexes; i++, xyz += 4, normal += 4 )
{
VectorScale( normal, scale, offset );
xyz[0] += offset[0];
xyz[1] += offset[1];
xyz[2] += offset[2];
}
} else
{
table = TableForFunc( ds->deformationWave.func );
for ( i = 0; i < tess.numVertexes; i++, xyz += 4, normal += 4 )
{
float off = ( xyz[0] + xyz[1] + xyz[2] ) * ds->deformationSpread;
scale = WAVEVALUE( table, ds->deformationWave.base,
ds->deformationWave.amplitude,
ds->deformationWave.phase + off,
ds->deformationWave.frequency );
VectorScale( normal, scale, offset );
xyz[0] += offset[0];
xyz[1] += offset[1];
xyz[2] += offset[2];
}
}
}
示例3: GM_CheckFireState
static void GM_CheckFireState( void )
{
if ( enemyCS4 )
{//if have a clear shot, always try
return;
}
if ( !VectorCompare( NPC->client->ps.velocity, vec3_origin ) )
{//if moving at all, don't do this
return;
}
//See if we should continue to fire on their last position
if ( !hitAlly4 && NPCInfo->enemyLastSeenTime > 0 )
{
if ( level.time - NPCInfo->enemyLastSeenTime < 10000 )
{
if ( !Q_irand( 0, 10 ) )
{
//Fire on the last known position
vec3_t muzzle, dir, angles;
qboolean tooClose = qfalse;
qboolean tooFar = qfalse;
float distThreshold;
float dist;
CalcEntitySpot( NPC, SPOT_HEAD, muzzle );
if ( VectorCompare( impactPos4, vec3_origin ) )
{//never checked ShotEntity this frame, so must do a trace...
trace_t tr;
//vec3_t mins = {-2,-2,-2}, maxs = {2,2,2};
vec3_t forward, end;
AngleVectors( NPC->client->ps.viewangles, forward, NULL, NULL );
VectorMA( muzzle, 8192, forward, end );
trap_Trace( &tr, muzzle, vec3_origin, vec3_origin, end, NPC->s.number, MASK_SHOT );
VectorCopy( tr.endpos, impactPos4 );
}
//see if impact would be too close to me
distThreshold = 16384/*128*128*/;//default
if ( NPC->s.weapon == WP_REPEATER )
{
if ( NPCInfo->scriptFlags&SCF_ALT_FIRE )
{
distThreshold = 65536/*256*256*/;
}
}
dist = DistanceSquared( impactPos4, muzzle );
if ( dist < distThreshold )
{//impact would be too close to me
tooClose = qtrue;
}
else if ( level.time - NPCInfo->enemyLastSeenTime > 5000 )
{//we've haven't seen them in the last 5 seconds
//see if it's too far from where he is
distThreshold = 65536/*256*256*/;//default
if ( NPC->s.weapon == WP_REPEATER )
{
if ( NPCInfo->scriptFlags&SCF_ALT_FIRE )
{
distThreshold = 262144/*512*512*/;
}
}
dist = DistanceSquared( impactPos4, NPCInfo->enemyLastSeenLocation );
if ( dist > distThreshold )
{//impact would be too far from enemy
tooFar = qtrue;
}
}
if ( !tooClose && !tooFar )
{//okay too shoot at last pos
VectorSubtract( NPCInfo->enemyLastSeenLocation, muzzle, dir );
VectorNormalize( dir );
vectoangles( dir, angles );
NPCInfo->desiredYaw = angles[YAW];
NPCInfo->desiredPitch = angles[PITCH];
shoot4 = qtrue;
faceEnemy4 = qfalse;
return;
}
}
}
}
}
示例4: ComputeColors
//.........这里部分代码省略.........
pStage->rgbGen != CGEN_VERTEX ) {
for ( i = 0; i < tess.numVertexes; i++ ) {
tess.svars.colors[i][3] = 0xff;
}
}
}
break;
case AGEN_CONST:
if ( pStage->rgbGen != CGEN_CONST ) {
for ( i = 0; i < tess.numVertexes; i++ ) {
tess.svars.colors[i][3] = pStage->constantColor[3];
}
}
break;
case AGEN_WAVEFORM:
RB_CalcWaveAlpha( &pStage->alphaWave, ( unsigned char * ) tess.svars.colors );
break;
case AGEN_LIGHTING_SPECULAR:
RB_CalcSpecularAlpha( ( unsigned char * ) tess.svars.colors );
break;
case AGEN_ENTITY:
RB_CalcAlphaFromEntity( ( unsigned char * ) tess.svars.colors );
break;
case AGEN_ONE_MINUS_ENTITY:
RB_CalcAlphaFromOneMinusEntity( ( unsigned char * ) tess.svars.colors );
break;
// Ridah
case AGEN_NORMALZFADE:
{
float alpha, range, lowest, highest, dot;
vec3_t worldUp;
qboolean zombieEffect = qfalse;
if ( VectorCompare( backEnd.currentEntity->e.fireRiseDir, vec3_origin ) ) {
VectorSet( backEnd.currentEntity->e.fireRiseDir, 0, 0, 1 );
}
if ( backEnd.currentEntity->e.hModel ) { // world surfaces dont have an axis
VectorRotate( backEnd.currentEntity->e.fireRiseDir, backEnd.currentEntity->e.axis, worldUp );
} else {
VectorCopy( backEnd.currentEntity->e.fireRiseDir, worldUp );
}
lowest = pStage->zFadeBounds[0];
if ( lowest == -1000 ) { // use entity alpha
lowest = backEnd.currentEntity->e.shaderTime;
zombieEffect = qtrue;
}
highest = pStage->zFadeBounds[1];
if ( highest == -1000 ) { // use entity alpha
highest = backEnd.currentEntity->e.shaderTime;
zombieEffect = qtrue;
}
range = highest - lowest;
for ( i = 0; i < tess.numVertexes; i++ ) {
dot = DotProduct( tess.normal[i], worldUp );
// special handling for Zombie fade effect
if ( zombieEffect ) {
alpha = (float)backEnd.currentEntity->e.shaderRGBA[3] * ( dot + 1.0 ) / 2.0;
alpha += ( 2.0 * (float)backEnd.currentEntity->e.shaderRGBA[3] ) * ( 1.0 - ( dot + 1.0 ) / 2.0 );
if ( alpha > 255.0 ) {
alpha = 255.0;
} else if ( alpha < 0.0 ) {
alpha = 0.0;
}
示例5: fire_lead
/*
=================
fire_lead
This is an internal support routine used for bullet/pellet based weapons.
=================
*/
static void fire_lead (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int te_impact, int hspread, int vspread, int mod)
{
trace_t tr;
vec3_t dir;
vec3_t forward, right, up;
vec3_t end;
float r;
float u;
vec3_t water_start;
qboolean water = false;
int content_mask = MASK_SHOT | MASK_WATER;
tr = gi.trace (self->s.origin, NULL, NULL, start, self, MASK_SHOT);
if (!(tr.fraction < 1.0))
{
vectoangles (aimdir, dir);
AngleVectors (dir, forward, right, up);
r = crandom()*hspread;
u = crandom()*vspread;
VectorMA (start, 8192, forward, end);
VectorMA (end, r, right, end);
VectorMA (end, u, up, end);
if (gi.pointcontents (start) & MASK_WATER)
{
water = true;
VectorCopy (start, water_start);
content_mask &= ~MASK_WATER;
}
tr = gi.trace (start, NULL, NULL, end, self, content_mask);
// see if we hit water
if (tr.contents & MASK_WATER)
{
int color;
water = true;
VectorCopy (tr.endpos, water_start);
if (!VectorCompare (start, tr.endpos))
{
if (tr.contents & CONTENTS_WATER)
{
if (strcmp(tr.surface->name, "*brwater") == 0)
color = SPLASH_BROWN_WATER;
else
color = SPLASH_BLUE_WATER;
}
else if (tr.contents & CONTENTS_SLIME)
color = SPLASH_SLIME;
else if (tr.contents & CONTENTS_LAVA)
color = SPLASH_LAVA;
else
color = SPLASH_UNKNOWN;
if (color != SPLASH_UNKNOWN)
{
gi.WriteByte (svc_temp_entity);
gi.WriteByte (TE_SPLASH);
gi.WriteByte (8);
gi.WritePosition (tr.endpos);
gi.WriteDir (tr.plane.normal);
gi.WriteByte (color);
gi.multicast (tr.endpos, MULTICAST_PVS);
}
// change bullet's course when it enters water
VectorSubtract (end, start, dir);
vectoangles (dir, dir);
AngleVectors (dir, forward, right, up);
r = crandom()*hspread*2;
u = crandom()*vspread*2;
VectorMA (water_start, 8192, forward, end);
VectorMA (end, r, right, end);
VectorMA (end, u, up, end);
}
// re-trace ignoring water this time
tr = gi.trace (water_start, NULL, NULL, end, self, MASK_SHOT);
}
}
// send gun puff / flash
if (!((tr.surface) && (tr.surface->flags & SURF_SKY)))
{
if (tr.fraction < 1.0)
{
if (tr.ent->takedamage)
{
T_Damage (tr.ent, self, self, aimdir, tr.endpos, tr.plane.normal, damage, kick, DAMAGE_BULLET, mod);
}
//.........这里部分代码省略.........
示例6: WriteSurfaceExtraFile
void WriteSurfaceExtraFile( const char *path )
{
char srfPath[ 1024 ];
FILE *sf;
surfaceExtra_t *se;
int i;
/* dummy check */
if( path == NULL || path[ 0 ] == '\0' )
return;
/* note it */
Sys_Printf( "--- WriteSurfaceExtraFile ---\n" );
/* open the file */
strcpy( srfPath, path );
StripExtension( srfPath );
strcat( srfPath, ".srf" );
Sys_Printf( "Writing %s\n", srfPath );
sf = fopen( srfPath, "w" );
if( sf == NULL )
Error( "Error opening %s for writing", srfPath );
/* lap through the extras list */
for( i = -1; i < numSurfaceExtras; i++ )
{
/* get extra */
se = GetSurfaceExtra( i );
/* default or surface num? */
if( i < 0 )
fprintf( sf, "default" );
else
fprintf( sf, "%d", i );
/* valid map drawsurf? */
if( se->mds == NULL )
fprintf( sf, "\n" );
else
{
fprintf( sf, " // %s V: %d I: %d %s\n",
surfaceTypes[ se->mds->type ],
se->mds->numVerts,
se->mds->numIndexes,
(se->mds->planar ? "planar" : "") );
}
/* open braces */
fprintf( sf, "{\n" );
/* shader */
if( se->si != NULL )
fprintf( sf, "\tshader %s\n", se->si->shader );
/* parent surface number */
if( se->parentSurfaceNum != seDefault.parentSurfaceNum )
fprintf( sf, "\tparent %d\n", se->parentSurfaceNum );
/* entity number */
if( se->entityNum != seDefault.entityNum )
fprintf( sf, "\tentity %d\n", se->entityNum );
/* cast shadows */
if( se->castShadows != seDefault.castShadows || se == &seDefault )
fprintf( sf, "\tcastShadows %d\n", se->castShadows );
/* recv shadows */
if( se->recvShadows != seDefault.recvShadows || se == &seDefault )
fprintf( sf, "\treceiveShadows %d\n", se->recvShadows );
/* lightmap sample size */
if( se->sampleSize != seDefault.sampleSize || se == &seDefault )
fprintf( sf, "\tsampleSize %d\n", se->sampleSize );
/* longest curve */
if( se->longestCurve != seDefault.longestCurve || se == &seDefault )
fprintf( sf, "\tlongestCurve %f\n", se->longestCurve );
/* lightmap axis vector */
if( VectorCompare( se->lightmapAxis, seDefault.lightmapAxis ) == qfalse )
fprintf( sf, "\tlightmapAxis ( %f %f %f )\n", se->lightmapAxis[ 0 ], se->lightmapAxis[ 1 ], se->lightmapAxis[ 2 ] );
/* close braces */
fprintf( sf, "}\n\n" );
}
/* close the file */
fclose( sf );
}
示例7: PM_VehicleImpact
void PM_VehicleImpact(bgEntity_t *pEnt, trace_t *trace)
{
// See if the vehicle has crashed into the ground.
Vehicle_t *pSelfVeh = pEnt->m_pVehicle;
float magnitude = VectorLength( pm->ps->velocity ) * pSelfVeh->m_pVehicleInfo->mass / 50.0f;
qboolean forceSurfDestruction = qfalse;
#ifdef QAGAME
gentity_t *hitEnt = trace!=NULL?&g_entities[trace->entityNum]:NULL;
if (!hitEnt ||
(pSelfVeh && pSelfVeh->m_pPilot &&
hitEnt && hitEnt->s.eType == ET_MISSILE && hitEnt->inuse &&
hitEnt->r.ownerNum == pSelfVeh->m_pPilot->s.number)
)
{
return;
}
if ( pSelfVeh//I have a vehicle struct
&& pSelfVeh->m_iRemovedSurfaces )//vehicle has bits removed
{//spiralling to our deaths, explode on any solid impact
if ( hitEnt->s.NPC_class == CLASS_VEHICLE )
{//hit another vehicle, explode!
//Give credit to whoever got me into this death spiral state
gentity_t *parent = (gentity_t *)pSelfVeh->m_pParentEntity;
gentity_t *killer = NULL;
if (parent->client->ps.otherKiller < ENTITYNUM_WORLD &&
parent->client->ps.otherKillerTime > level.time)
{
gentity_t *potentialKiller = &g_entities[parent->client->ps.otherKiller];
if (potentialKiller->inuse && potentialKiller->client)
{ //he's valid I guess
killer = potentialKiller;
}
}
//FIXME: damage hitEnt, some, too? Our explosion should hurt them some, but...
G_Damage( (gentity_t *)pEnt, killer, killer, NULL, pm->ps->origin, 999999, DAMAGE_NO_ARMOR, MOD_FALLING );//FIXME: MOD_IMPACT
return;
}
else if ( !VectorCompare( trace->plane.normal, vec3_origin )
&& (trace->entityNum == ENTITYNUM_WORLD || hitEnt->r.bmodel ) )
{//have a valid hit plane and we hit a solid brush
vec3_t moveDir;
float impactDot;
VectorCopy( pm->ps->velocity, moveDir );
VectorNormalize( moveDir );
impactDot = DotProduct( moveDir, trace->plane.normal );
if ( impactDot <= -0.7f )//hit rather head-on and hard
{// Just DIE now
//Give credit to whoever got me into this death spiral state
gentity_t *parent = (gentity_t *)pSelfVeh->m_pParentEntity;
gentity_t *killer = NULL;
if (parent->client->ps.otherKiller < ENTITYNUM_WORLD &&
parent->client->ps.otherKillerTime > level.time)
{
gentity_t *potentialKiller = &g_entities[parent->client->ps.otherKiller];
if (potentialKiller->inuse && potentialKiller->client)
{ //he's valid I guess
killer = potentialKiller;
}
}
G_Damage( (gentity_t *)pEnt, killer, killer, NULL, pm->ps->origin, 999999, DAMAGE_NO_ARMOR, MOD_FALLING );//FIXME: MOD_IMPACT
return;
}
}
}
if ( trace->entityNum < ENTITYNUM_WORLD
&& hitEnt->s.eType == ET_MOVER
&& hitEnt->s.apos.trType != TR_STATIONARY//rotating
&& (hitEnt->spawnflags&16) //IMPACT
&& Q_stricmp( "func_rotating", hitEnt->classname ) == 0 )
{//hit a func_rotating that is supposed to destroy anything it touches!
//guarantee the hit will happen, thereby taking off a piece of the ship
forceSurfDestruction = qtrue;
}
else if ( (fabs(pm->ps->velocity[0])+fabs(pm->ps->velocity[1])) < 100.0f
&& pm->ps->velocity[2] > -100.0f )
#else
if ( (fabs(pm->ps->velocity[0])+fabs(pm->ps->velocity[1])) < 100.0f
&& pm->ps->velocity[2] > -100.0f )
#endif
/*
if ( (pSelfVeh->m_ulFlags&VEH_GEARSOPEN)
&& trace->plane.normal[2] > 0.7f
&& fabs(pSelfVeh->m_vOrientation[PITCH]) < 0.2f
&& fabs(pSelfVeh->m_vOrientation[ROLL]) < 0.2f )*/
{//we're landing, we're cool
//this was annoying me -rww
//FIXME: this shouldn't even be getting called when the vehicle is at rest!
#ifdef QAGAME
if (hitEnt && (hitEnt->s.eType == ET_PLAYER || hitEnt->s.eType == ET_NPC) && pSelfVeh->m_pVehicleInfo->type == VH_FIGHTER)
{ //always smack players
}
else
#endif
{
return;
//.........这里部分代码省略.........
示例8: RE_GL_AddDecal
/*
=================
RE_AddDecal
Adds a single decal to the decal list
=================
*/
void RE_GL_AddDecal (vec3_t origin, vec3_t dir, vec4_t color, float size, int type, int flags, float angle)
{
int i, j, numfragments;
vec3_t verts[MAX_DECAL_VERTS], shade, temp;
markFragment_t *fr, fragments[MAX_FRAGMENTS_PER_DECAL];
vec3_t axis[3];
cdecal_t *d;
float lightspot[3];
if (!gl_decals->value)
return;
// invalid decal size
if (size <= 0)
return;
// a hack to produce decals from explosions etc
if (VectorCompare(dir, vec3_origin))
{
float scale = 1.5 * size;
trace_t trace;
vec3_t end, dirs[6] = {
{ 1.0, 0.0, 0.0 },
{ -1.0, 0.0, 0.0 },
{ 0.0, 1.0, 0.0 },
{ 0.0, -1.0, 0.0 },
{ 0.0, 0.0, 1.0 },
{ 0.0, 0.0, -1.0 }
};
for (i = 0; i < 6; i++)
{
VectorMA(origin, scale, dirs[i], end);
trace = CL_Trace(origin, end, 0, MASK_SOLID);
if (trace.fraction != 1.0)
RE_GL_AddDecal(origin, trace.plane.normal, color, size, type, flags, angle);
}
return;
}
// calculate orientation matrix
VectorNormalize2(dir, axis[0]);
PerpendicularVector(axis[1], axis[0]);
RotatePointAroundVector(axis[2], axis[0], axis[1], angle);
CrossProduct(axis[0], axis[2], axis[1]);
// clip it against the world
numfragments = R_GetClippedFragments(origin, axis, size, MAX_DECAL_VERTS, verts, MAX_FRAGMENTS_PER_DECAL, fragments);
if (!numfragments)
return; // no valid fragments
// store out vertex data
size = 0.5f / size;
VectorScale(axis[1], size, axis[1]);
VectorScale(axis[2], size, axis[2]);
for (i = 0, fr = fragments; i < numfragments; i++, fr++)
{
// check if we have hit the max
if (fr->numPoints > MAX_DECAL_VERTS)
fr->numPoints = MAX_DECAL_VERTS;
else if (fr->numPoints <= 0)
continue;
d = R_AllocDecal();
d->time = r_newrefdef.time;
d->node = fr->node;
VectorCopy(fr->surf->plane->normal, d->direction);
if (!(fr->surf->flags & SURF_PLANEBACK))
VectorNegate(d->direction, d->direction); // reverse direction
Vector4Set(d->color, color[0], color[1], color[2], color[3]);
VectorCopy(origin, d->org);
//if (flags & DF_SHADE)
{
R_LightPoint(origin, shade, lightspot);
for (j = 0; j < 3; j++)
d->color[j] = (d->color[j] * shade[j] * 0.6) + (d->color[j] * 0.4);
}
d->type = type;
d->flags = flags;
// make the decal vert
d->numverts = fr->numPoints;
for (j = 0; j < fr->numPoints && j < MAX_VERTS_PER_FRAGMENT; j++)
{
// xyz
VectorCopy(verts[fr->firstPoint + j], d->verts[j]);
//.........这里部分代码省略.........
示例9: VectorSubtract
void Winding::RemoveColinearPoints()
{
unsigned int i;
unsigned int nump;
int j;
vec3_t v1, v2;
vec3_t p[128];
//JK: Did the optimizations...
if (m_NumPoints>1)
{
VectorSubtract(m_Points[0], m_Points[m_NumPoints - 1], v2);
VectorNormalize(v2);
}
nump=0;
for (i = 0; i < m_NumPoints; i++)
{
j = (i + 1) % m_NumPoints; // i + 1
VectorSubtract(m_Points[i], m_Points[j], v1);
VectorNormalize(v1);
VectorAdd(v1, v2, v2);
if (!VectorCompare(v2, vec3_origin))
{
VectorCopy(m_Points[i], p[nump]);
nump++;
}
#if 0
else
{
Log("v3 was (%4.3f %4.3f %4.3f)\n", v2[0], v2[1], v2[2]);
}
#endif
//Set v2 for next round
v2[0]=-v1[0];
v2[1]=-v1[1];
v2[2]=-v1[2];
}
if (nump == m_NumPoints)
{
return;
}
#if 0
Warning("RemoveColinearPoints: Removed %u points, from %u to %u\n", m_NumPoints - nump, m_NumPoints, nump);
Warning("Before :\n");
Print();
#endif
m_NumPoints = nump;
memcpy(m_Points, p, nump * sizeof(vec3_t));
#if 0
Warning("After :\n");
Print();
Warning("==========\n");
#endif
}
示例10: TEST_F
TEST_F(GameTest, InventoryWithTwoDiedAliensOnTheSameGridTile)
{
const char* mapName = "test_game";
ASSERT_NE(-1, FS_CheckFile("maps/%s.bsp", mapName)) << "Map resource '" << mapName << ".bsp' for test is missing.";
Actor* diedEnt;
Actor* diedEnt2;
Actor* actor;
Edict* floorItems;
Item* invlist;
int count;
SV_Map(true, mapName, nullptr);
level.activeTeam = TEAM_ALIEN;
/* first alien that should die and drop its inventory */
diedEnt = G_EdictsGetNextLivingActorOfTeam(nullptr, TEAM_ALIEN);
ASSERT_TRUE(nullptr != diedEnt) << "No living actor in the alien team";
diedEnt->HP = 0;
G_ActorDieOrStun(diedEnt, nullptr);
ASSERT_TRUE(diedEnt->isDead()) << "Actor is not dead";
/* second alien that should die and drop its inventory */
diedEnt2 = G_EdictsGetNextLivingActorOfTeam(nullptr, TEAM_ALIEN);
ASSERT_TRUE(nullptr != diedEnt2) << "No living actor in the alien team";
/* move to the location of the first died alien to drop the inventory into the same floor container */
Player& player = diedEnt2->getPlayer();
ASSERT_TRUE(G_IsAIPlayer(&player));
G_ClientMove(player, 0, diedEnt2, diedEnt->pos);
ASSERT_TRUE(VectorCompare(diedEnt2->pos, diedEnt->pos));
diedEnt2->HP = 0;
G_ActorDieOrStun(diedEnt2, nullptr);
ASSERT_TRUE(diedEnt2->isDead()) << "Actor is not dead";
/* now try to collect the inventory with a third alien */
actor = G_EdictsGetNextLivingActorOfTeam(nullptr, TEAM_ALIEN);
ASSERT_TRUE(nullptr != actor) << "No living actor in the alien team";
player = actor->getPlayer();
ASSERT_TRUE(G_IsAIPlayer(&player)) << "Player is not ai controlled";
G_ClientMove(player, 0, actor, diedEnt->pos);
ASSERT_TRUE(VectorCompare(actor->pos, diedEnt->pos)) << "Actor is not at the same position as the died entity";
floorItems = G_GetFloorItems(actor);
ASSERT_TRUE(nullptr != floorItems);
ASSERT_EQ(floorItems->getFloor(), actor->getFloor());
/* drop everything to floor to make sure we have space in the backpack */
G_InventoryToFloor(actor);
ASSERT_EQ(0, GAMETEST_GetItemCount(actor, CID_BACKPACK));
invlist = actor->getContainer(CID_BACKPACK);
ASSERT_TRUE(nullptr == invlist);
count = GAMETEST_GetItemCount(actor, CID_FLOOR);
if (count > 0) {
Item* entryToMove = actor->getFloor();
int tx, ty;
actor->chr.inv.findSpace(INVDEF(CID_BACKPACK), entryToMove, &tx, &ty, entryToMove);
if (tx == NONE)
return;
Com_Printf("trying to move item %s from floor into backpack to pos %i:%i\n", entryToMove->def()->name, tx, ty);
ASSERT_TRUE(G_ActorInvMove(actor, INVDEF(CID_FLOOR), entryToMove, INVDEF(CID_BACKPACK), tx, ty, false));
ASSERT_EQ(GAMETEST_GetItemCount(actor, CID_FLOOR), count - 1) << "item " << entryToMove->def()->name << " could not get moved successfully from floor into backpack";
Com_Printf("item %s was removed from floor\n", entryToMove->def()->name);
ASSERT_EQ(GAMETEST_GetItemCount(actor, CID_BACKPACK), 1) << "item " << entryToMove->def()->name << " could not get moved successfully from floor into backpack";
Com_Printf("item %s was moved successfully into the backpack\n", entryToMove->def()->name);
invlist = actor->getContainer(CID_BACKPACK);
ASSERT_TRUE(nullptr != invlist);
}
}
示例11: SV_LinkEntity
void SV_LinkEntity(sharedEntity_t *gEnt)
{
worldSector_t *node;
int leafs[MAX_TOTAL_ENT_LEAFS];
int cluster;
int num_leafs;
int i, j, k;
int area;
int lastLeaf;
float *origin, *angles;
svEntity_t *ent;
ent = SV_SvEntityForGentity(gEnt);
// Ridah, sanity check for possible currentOrigin being reset bug
if(!gEnt->r.bmodel && VectorCompare(gEnt->r.currentOrigin, vec3_origin))
{
Com_DPrintf("WARNING: BBOX entity is being linked at world origin, this is probably a bug\n");
}
if(ent->worldSector)
{
SV_UnlinkEntity(gEnt); // unlink from old position
}
// encode the size into the entityState_t for client prediction
if(gEnt->r.bmodel)
{
gEnt->s.solid = SOLID_BMODEL; // a solid_box will never create this value
}
else if(gEnt->r.contents & (CONTENTS_SOLID | CONTENTS_BODY))
{
// assume that x/y are equal and symetric
i = gEnt->r.maxs[0];
if(i < 1)
{
i = 1;
}
if(i > 255)
{
i = 255;
}
// z is not symetric
j = (-gEnt->r.mins[2]);
if(j < 1)
{
j = 1;
}
if(j > 255)
{
j = 255;
}
// and z maxs can be negative...
k = (gEnt->r.maxs[2] + 32);
if(k < 1)
{
k = 1;
}
if(k > 255)
{
k = 255;
}
gEnt->s.solid = (k << 16) | (j << 8) | i;
}
else
{
gEnt->s.solid = 0;
}
// get the position
origin = gEnt->r.currentOrigin;
angles = gEnt->r.currentAngles;
// set the abs box
if(gEnt->r.bmodel && (angles[0] || angles[1] || angles[2]))
{
// expand for rotation
float max;
int i;
max = RadiusFromBounds(gEnt->r.mins, gEnt->r.maxs);
for(i = 0 ; i < 3 ; i++)
{
gEnt->r.absmin[i] = origin[i] - max;
gEnt->r.absmax[i] = origin[i] + max;
}
}
else
{
// normal
//.........这里部分代码省略.........
示例12: R_LoadMD5
//.........这里部分代码省略.........
{
v->weights[ k ] = surf->weights + ( v->firstWeight + k );
}
}
}
// loading is done now calculate the bounding box and tangent spaces
ClearBounds( md5->bounds[ 0 ], md5->bounds[ 1 ] );
for ( i = 0, surf = md5->surfaces; i < md5->numSurfaces; i++, surf++ )
{
for ( j = 0, v = surf->verts; j < surf->numVerts; j++, v++ )
{
vec3_t tmpVert;
md5Weight_t *w;
VectorClear( tmpVert );
for ( k = 0, w = v->weights[ 0 ]; k < v->numWeights; k++, w++ )
{
vec3_t offsetVec;
bone = &md5->bones[ w->boneIndex ];
QuatTransformVector( bone->rotation, w->offset, offsetVec );
VectorAdd( bone->origin, offsetVec, offsetVec );
VectorMA( tmpVert, w->boneWeight, offsetVec, tmpVert );
}
VectorCopy( tmpVert, v->position );
AddPointToBounds( tmpVert, md5->bounds[ 0 ], md5->bounds[ 1 ] );
}
// calc normals
{
const float *v0, *v1, *v2;
const float *t0, *t1, *t2;
vec3_t normal;
for ( j = 0, v = surf->verts; j < surf->numVerts; j++, v++ )
{
VectorClear( v->tangent );
VectorClear( v->binormal );
VectorClear( v->normal );
}
for ( j = 0, tri = surf->triangles; j < surf->numTriangles; j++, tri++ )
{
v0 = surf->verts[ tri->indexes[ 0 ] ].position;
v1 = surf->verts[ tri->indexes[ 1 ] ].position;
v2 = surf->verts[ tri->indexes[ 2 ] ].position;
t0 = surf->verts[ tri->indexes[ 0 ] ].texCoords;
t1 = surf->verts[ tri->indexes[ 1 ] ].texCoords;
t2 = surf->verts[ tri->indexes[ 2 ] ].texCoords;
R_CalcNormalForTriangle( normal, v0, v1, v2 );
for ( k = 0; k < 3; k++ )
{
float *v;
v = surf->verts[ tri->indexes[ k ] ].normal;
VectorAdd( v, normal, v );
}
}
for ( j = 0, v = surf->verts; j < surf->numVerts; j++, v++ )
{
VectorNormalize( v->normal );
}
}
#if 0
// do another extra smoothing for normals to avoid flat shading
for ( j = 0; j < surf->numVerts; j++ )
{
for ( k = 0; k < surf->numVerts; k++ )
{
if ( j == k )
{
continue;
}
if ( VectorCompare( surf->verts[ j ].position, surf->verts[ k ].position ) )
{
VectorAdd( surf->verts[ j ].normal, surf->verts[ k ].normal, surf->verts[ j ].normal );
}
}
VectorNormalize( surf->verts[ j ].normal );
}
#endif
}
return qtrue;
}
示例13: G_RunMissile
void G_RunMissile( gentity_t *ent )
{
vec3_t oldOrg;
trace_t tr;
int trHitLoc=HL_NONE;
if ( (ent->s.eFlags&EF_HELD_BY_SAND_CREATURE) )
{//in a sand creature's mouth
if ( ent->activator )
{
mdxaBone_t boltMatrix;
// Getting the bolt here
//in hand
vec3_t scAngles = {0};
scAngles[YAW] = ent->activator->currentAngles[YAW];
gi.G2API_GetBoltMatrix( ent->activator->ghoul2, ent->activator->playerModel, ent->activator->gutBolt,
&boltMatrix, scAngles, ent->activator->currentOrigin, (cg.time?cg.time:level.time),
NULL, ent->activator->s.modelScale );
// Storing ent position, bolt position, and bolt axis
gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, ent->currentOrigin );
G_SetOrigin( ent, ent->currentOrigin );
}
// check think function
G_RunThink( ent );
return;
}
VectorCopy( ent->currentOrigin, oldOrg );
// get current position
if ( ent->s.pos.trType == TR_INTERPOLATE )
{//rolling missile?
//FIXME: WTF?!! Sticks to stick missiles?
//FIXME: they stick inside the player
G_RollMissile( ent );
if ( ent->s.eType != ET_GENERAL )
{//didn't explode
VectorCopy( ent->currentOrigin, ent->s.pos.trBase );
gi.trace( &tr, oldOrg, ent->mins, ent->maxs, ent->currentOrigin, ent->s.number, ent->clipmask, G2_RETURNONHIT, 10 );
if ( VectorCompare( ent->s.pos.trDelta, vec3_origin ) )
{
//VectorCopy( ent->currentAngles, ent->s.apos.trBase );
VectorClear( ent->s.apos.trDelta );
}
else
{
vec3_t ang, fwdDir, rtDir;
float speed;
ent->s.apos.trType = TR_INTERPOLATE;
VectorSet( ang, 0, ent->s.apos.trBase[1], 0 );
AngleVectors( ang, fwdDir, rtDir, NULL );
speed = VectorLength( ent->s.pos.trDelta )*4;
//HMM, this works along an axis-aligned dir, but not along diagonals
//This is because when roll gets to 90, pitch becomes yaw, and vice-versa
//Maybe need to just set the angles directly?
ent->s.apos.trDelta[0] = DotProduct( fwdDir, ent->s.pos.trDelta );
ent->s.apos.trDelta[1] = 0;//never spin!
ent->s.apos.trDelta[2] = DotProduct( rtDir, ent->s.pos.trDelta );
VectorNormalize( ent->s.apos.trDelta );
VectorScale( ent->s.apos.trDelta, speed, ent->s.apos.trDelta );
ent->s.apos.trTime = level.previousTime;
}
}
}
else
{
vec3_t origin;
EvaluateTrajectory( &ent->s.pos, level.time, origin );
// trace a line from the previous position to the current position,
// ignoring interactions with the missile owner
gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin,
ent->owner ? ent->owner->s.number : ent->s.number, ent->clipmask, G2_COLLIDE, 10 );
if ( tr.entityNum != ENTITYNUM_NONE )
{
gentity_t *other = &g_entities[tr.entityNum];
// check for hitting a lightsaber
if ( other->contents & CONTENTS_LIGHTSABER )
{//hit a lightsaber bbox
if ( other->owner
&& other->owner->client
&& !other->owner->client->ps.saberInFlight
&& ( Q_irand( 0, (other->owner->client->ps.forcePowerLevel[FP_SABER_DEFENSE]*other->owner->client->ps.forcePowerLevel[FP_SABER_DEFENSE]) ) == 0
|| !InFront( ent->currentOrigin, other->owner->currentOrigin, other->owner->client->ps.viewangles, SABER_REFLECT_MISSILE_CONE ) ) )//other->owner->s.number == 0 &&
{//Jedi cannot block shots from behind!
//re-trace from here, ignoring the lightsaber
gi.trace( &tr, tr.endpos, ent->mins, ent->maxs, origin, tr.entityNum, ent->clipmask, G2_RETURNONHIT, 10 );
}
}
}
VectorCopy( tr.endpos, ent->currentOrigin );
}
// get current angles
VectorMA( ent->s.apos.trBase, (level.time - ent->s.apos.trTime) * 0.001, ent->s.apos.trDelta, ent->s.apos.trBase );
//.........这里部分代码省略.........
示例14: R_LoadPSK
//.........这里部分代码省略.........
VectorAdd(dv[k]->normal, faceNormal, dv[k]->normal);
#endif
}
}
#if 1
for(j = 0; j < vboVertexes.currentElements; j++)
{
dv[0] = Com_GrowListElement(&vboVertexes, j);
//VectorNormalize(dv[0]->tangent);
//VectorNormalize(dv[0]->binormal);
VectorNormalize(dv[0]->normal);
}
#endif
}
#endif
#if 0
{
md5Vertex_t *v0, *v1;
// do another extra smoothing for normals to avoid flat shading
for(j = 0; j < vboVertexes.currentElements; j++)
{
v0 = Com_GrowListElement(&vboVertexes, j);
for(k = 0; k < vboVertexes.currentElements; k++)
{
if(j == k)
continue;
v1 = Com_GrowListElement(&vboVertexes, k);
if(VectorCompare(v0->position, v1->position))
{
VectorAdd(v0->position, v1->normal, v0->normal);
}
}
VectorNormalize(v0->normal);
}
}
#endif
// split the surfaces into VBO surfaces by the maximum number of GPU vertex skinning bones
Com_InitGrowList(&vboSurfaces, 10);
materialIndex = oldMaterialIndex = -1;
for(i = 0; i < numTriangles; i++)
{
triangle = &triangles[i];
materialIndex = triangle->materialIndex;
if(materialIndex != oldMaterialIndex)
{
oldMaterialIndex = materialIndex;
numRemaining = sortedTriangles.currentElements - i;
while(numRemaining)
{
numBoneReferences = 0;
Com_Memset(boneReferences, 0, sizeof(boneReferences));
Com_InitGrowList(&vboTriangles, 1000);
for(j = i; j < sortedTriangles.currentElements; j++)
示例15: sphere_chase
// =================
void sphere_chase (edict_t *self, int stupidChase)
{
vec3_t dest;
vec3_t dir;
float dist;
if(level.time >= self->wait || (self->enemy && self->enemy->health < 1))
{
sphere_think_explode(self);
return;
}
VectorCopy (self->enemy->s.origin, dest);
if(self->enemy->client)
dest[2] += self->enemy->viewheight;
if(visible(self, self->enemy) || stupidChase)
{
// if moving, hunter sphere uses active sound
if(!stupidChase)
self->s.sound = gi.soundindex ("spheres/h_active.wav");
VectorSubtract (dest, self->s.origin, dir);
VectorNormalize (dir);
vectoangles2(dir, self->s.angles);
VectorScale (dir, 500, self->velocity);
VectorCopy(dest, self->monsterinfo.saved_goal);
}
else if (VectorCompare (self->monsterinfo.saved_goal, vec3_origin))
{
VectorSubtract(self->enemy->s.origin, self->s.origin, dir);
vectoangles2(dir, self->s.angles);
// if lurking, hunter sphere uses lurking sound
self->s.sound = gi.soundindex ("spheres/h_lurk.wav");
VectorClear (self->velocity);
}
else
{
VectorSubtract(self->monsterinfo.saved_goal, self->s.origin, dir);
dist = VectorNormalize(dir);
if(dist > 1)
{
vectoangles2(dir, self->s.angles);
if(dist > 500)
VectorScale(dir, 500, self->velocity);
else if (dist < 20)
VectorScale(dir, (dist / FRAMETIME), self->velocity);
else
VectorScale(dir, dist, self->velocity);
// if moving, hunter sphere uses active sound
if(!stupidChase)
self->s.sound = gi.soundindex ("spheres/h_active.wav");
}
else
{
VectorSubtract(self->enemy->s.origin, self->s.origin, dir);
vectoangles2(dir, self->s.angles);
// if not moving, hunter sphere uses lurk sound
if(!stupidChase)
self->s.sound = gi.soundindex ("spheres/h_lurk.wav");
VectorClear(self->velocity);
}
}
}