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


C++ CM_TransformedBoxTrace函数代码示例

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


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

示例1: SV_ClipMoveToEntities

/*
 * ==================== SV_ClipMoveToEntities
 *
 * ====================
 */
void
SV_ClipMoveToEntities(moveclip_t * clip)
{
	int		i, num;
	edict_t        *touchlist[MAX_EDICTS], *touch;
	trace_t		trace;
	int		headnode;
	float          *angles;

	num = SV_AreaEdicts(clip->boxmins, clip->boxmaxs, touchlist
	    ,MAX_EDICTS, AREA_SOLID);

	/* be careful, it is possible to have an entity in this */
	/* list removed before we get to it (killtriggered) */
	for (i = 0; i < num; i++) {
		touch = touchlist[i];
		if (touch->solid == SOLID_NOT)
			continue;
		if (touch == clip->passedict)
			continue;
		if (clip->trace.allsolid)
			return;
		if (clip->passedict) {
			if (touch->owner == clip->passedict)
				continue;	/* don't clip against own
						 * missiles */
			if (clip->passedict->owner == touch)
				continue;	/* don't clip against owner */
		}
		if (!(clip->contentmask & CONTENTS_DEADMONSTER)
		    && (touch->svflags & SVF_DEADMONSTER))
			continue;

		/* might intersect, so do an exact clip */
		headnode = SV_HullForEntity(touch);
		angles = touch->s.angles;
		if (touch->solid != SOLID_BSP)
			angles = vec3_origin;	/* boxes don't rotate */

		if (touch->svflags & SVF_MONSTER)
			trace = CM_TransformedBoxTrace(clip->start, clip->end,
			    clip->mins2, clip->maxs2, headnode, clip->contentmask,
			    touch->s.origin, angles);
		else
			trace = CM_TransformedBoxTrace(clip->start, clip->end,
			    clip->mins, clip->maxs, headnode, clip->contentmask,
			    touch->s.origin, angles);

		if (trace.allsolid || trace.startsolid ||
		    trace.fraction < clip->trace.fraction) {
			trace.ent = touch;
			if (clip->trace.startsolid) {
				clip->trace = trace;
				clip->trace.startsolid = true;
			} else
				clip->trace = trace;
		} else if (trace.startsolid)
			clip->trace.startsolid = true;
	}
}
开发者ID:ZwS,项目名称:qudos,代码行数:65,代码来源:sv_world.c

示例2: SV_ClipToEntity

/*
====================
SV_ClipToEntity

====================
*/
void SV_ClipToEntity( trace_t *trace, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int entityNum, int contentmask, int capsule ) {
	sharedEntity_t	*touch;
	clipHandle_t	clipHandle;
	float			*origin, *angles;

	touch = SV_GentityNum( entityNum );

	Com_Memset(trace, 0, sizeof(trace_t));

	// if it doesn't have any brushes of a type we
	// are looking for, ignore it
	if ( ! ( contentmask & touch->r.contents ) ) {
		trace->fraction = 1.0;
		return;
	}

	// might intersect, so do an exact clip
	clipHandle = SV_ClipHandleForEntity (touch);

	origin = touch->r.currentOrigin;
	angles = touch->r.currentAngles;

	if ( !touch->r.bmodel ) {
		angles = vec3_origin;	// boxes don't rotate
	}

	CM_TransformedBoxTrace ( trace, (float *)start, (float *)end,
		(float *)mins, (float *)maxs, clipHandle,  contentmask,
		origin, angles, capsule);

	if ( trace->fraction < 1 ) {
		trace->entityNum = touch->s.number;
	}
}
开发者ID:Lrns123,项目名称:jkaq3,代码行数:40,代码来源:sv_world.c

示例3: TV_Module_CM_TransformedBoxTrace

static inline void TV_Module_CM_TransformedBoxTrace( relay_t *relay, trace_t *tr, vec3_t start, vec3_t end,
													vec3_t mins, vec3_t maxs, struct cmodel_s *cmodel, int brushmask, vec3_t origin, vec3_t angles )
{
	if( !relay )
	{
		Com_Printf( "Error: TV_Module_CM_TransformedBoxTrace: Relay not set\n" );
		return;
	}

	CM_TransformedBoxTrace( relay->cms, tr, start, end, mins, maxs, cmodel, brushmask, origin, angles );
}
开发者ID:Clever-Boy,项目名称:qfusion,代码行数:11,代码来源:tv_relay_module.c

示例4: CM_HeadnodeForBoxHull

bool CEngineTrace::ClipRayToBBox( const Ray_t &ray, unsigned int fMask, ICollideable *pEntity, trace_t *pTrace )
{
	if ( pEntity->GetSolid() != SOLID_BBOX )
		return false;

	int nHeadNode = CM_HeadnodeForBoxHull( pEntity->WorldAlignMins(), pEntity->WorldAlignMaxs() );

	// bboxes don't rotate
	CM_TransformedBoxTrace( ray, nHeadNode, fMask, pEntity->GetCollisionOrigin(), vec3_angle, *pTrace );
	return true;
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:11,代码来源:enginetrace.cpp

示例5: EnumElement

	IterationRetval_t EnumElement( IHandleEntity *pHandleEntity )
	{
		// Static props should never be in the trigger list 
		Assert( !StaticPropMgr()->IsStaticProp( pHandleEntity ) );

		IServerNetworkable *pNetworkable = static_cast<IServerNetworkable*>( pHandleEntity );
		Assert( pNetworkable );

		// Convert the IHandleEntity to an edict_t*...
		// Context is the thing we're testing everything against		
		edict_t* pTouch = pNetworkable->GetEdict();

		// Can't bump against itself
		if ( pTouch == m_pEnt )
			return ITERATION_CONTINUE;

		IServerEntity *serverEntity = pTouch->GetIServerEntity();
		if ( !serverEntity )
			return ITERATION_CONTINUE;

		// Hmmm.. everything in this list should be a trigger....
		ICollideable *pCollideable = serverEntity->GetCollideable();
		Assert(pCollideable->GetSolidFlags() & FSOLID_TRIGGER );
		if ( (pCollideable->GetSolidFlags() & FSOLID_TRIGGER) == 0 )
			return ITERATION_CONTINUE;

		model_t* pModel = sv.GetModel( pCollideable->GetCollisionModelIndex() );
		if ( pModel && pModel->type == mod_brush )
		{
			int headnode = SV_HullForEntity( pTouch );

			int contents;
			if (!m_Ray.m_IsSwept)
			{
				contents = CM_TransformedBoxContents( m_Ray.m_Start, m_mins, m_maxs,
					headnode, serverEntity->GetAbsOrigin(), serverEntity->GetAbsAngles() );
			}
			else
			{
				trace_t trace;
				CM_TransformedBoxTrace( m_Ray, headnode, MASK_ALL, serverEntity->GetAbsOrigin(), 
					serverEntity->GetAbsAngles(), trace );
				contents = trace.contents;
			}

			if ( !(contents & MASK_SOLID) )
				return ITERATION_CONTINUE;
		}

		m_TouchedEntities.AddToTail( pTouch );

		return ITERATION_CONTINUE;
	}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:53,代码来源:world.cpp

示例6: SV_EntityContact

/*
==================
SV_GameAreaEntities
==================
*/
bool SV_EntityContact(vec3_t mins, vec3_t maxs, const sharedEntity_t * gEnt, traceType_t type) {
	const float		*origin, *angles;
	clipHandle_t	ch;
	trace_t			trace;

	// check for exact collision
	origin = gEnt->r.currentOrigin;
	angles = gEnt->r.currentAngles;

	ch = SV_ClipHandleForEntity( gEnt );
	CM_TransformedBoxTrace(&trace, vec3_origin, vec3_origin, mins, maxs, ch, -1, origin, angles, type);

	return trace.startsolid;
}
开发者ID:TheDushan,项目名称:OpenWolf,代码行数:19,代码来源:sv_game.cpp

示例7: CM_InlineModelNumber

//-----------------------------------------------------------------------------
// Perform bsp trace
//-----------------------------------------------------------------------------
bool CEngineTrace::ClipRayToBSP( const Ray_t &ray, unsigned int fMask, ICollideable *pEntity, trace_t *pTrace )
{
	const model_t *pModel = pEntity->GetCollisionModel();
	if ( pModel && pModel->type == mod_brush )
	{
		int nModelIndex = pEntity->GetCollisionModelIndex();
		cmodel_t *pCModel = CM_InlineModelNumber( nModelIndex - 1 );
		int nHeadNode = pCModel->headnode;

		CM_TransformedBoxTrace( ray, nHeadNode, fMask, pEntity->GetCollisionOrigin(), pEntity->GetCollisionAngles(), *pTrace );
		return true;
	}
	return false;
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:17,代码来源:enginetrace.cpp

示例8: SV_ClipMoveToEntities

/*
====================
SV_ClipMoveToEntities

====================
*/
static void SV_ClipMoveToEntities(vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end,
                                  edict_t *passedict, int contentmask, trace_t *tr)
{
    vec3_t      boxmins, boxmaxs;
    int         i, num;
    edict_t     *touchlist[MAX_EDICTS], *touch;
    trace_t     trace;

    // create the bounding box of the entire move
    for (i = 0; i < 3; i++) {
        if (end[i] > start[i]) {
            boxmins[i] = start[i] + mins[i] - 1;
            boxmaxs[i] = end[i] + maxs[i] + 1;
        } else {
            boxmins[i] = end[i] + mins[i] - 1;
            boxmaxs[i] = start[i] + maxs[i] + 1;
        }
    }

    num = SV_AreaEdicts(boxmins, boxmaxs, touchlist, MAX_EDICTS, AREA_SOLID);

    // be careful, it is possible to have an entity in this
    // list removed before we get to it (killtriggered)
    for (i = 0; i < num; i++) {
        touch = touchlist[i];
        if (touch->solid == SOLID_NOT)
            continue;
        if (touch == passedict)
            continue;
        if (tr->allsolid)
            return;
        if (passedict) {
            if (touch->owner == passedict)
                continue;    // don't clip against own missiles
            if (passedict->owner == touch)
                continue;    // don't clip against owner
        }

        if (!(contentmask & CONTENTS_DEADMONSTER)
            && (touch->svflags & SVF_DEADMONSTER))
            continue;

        // might intersect, so do an exact clip
        CM_TransformedBoxTrace(&trace, start, end, mins, maxs,
                               SV_HullForEntity(touch), contentmask,
                               touch->s.origin, touch->s.angles);

        CM_ClipEntity(tr, &trace, touch);
    }
}
开发者ID:Jenco420,项目名称:q2pro,代码行数:56,代码来源:world.c

示例9: R_Trace

/**
 * @brief Moves the given mins/maxs volume through the world from start to end.
 * @param[in] start Start vector to start the trace from
 * @param[in] end End vector to stop the trace at
 * @param[in] size Bounding box size used for tracing
 * @param[in] contentmask Searched content the trace should watch for
 */
void R_Trace (const vec3_t start, const vec3_t end, float size, int contentmask)
{
	vec3_t mins, maxs;
	float frac;
	trace_t tr;
	int i;

	r_locals.tracenum++;

	if (r_locals.tracenum > 0xffff)  /* avoid overflows */
		r_locals.tracenum = 0;

	VectorSet(mins, -size, -size, -size);
	VectorSet(maxs, size, size, size);

	refdef.trace = CM_CompleteBoxTrace(refdef.mapTiles, start, end, mins, maxs, TRACING_ALL_VISIBLE_LEVELS, contentmask, 0);
	refdef.traceEntity = NULL;

	frac = refdef.trace.fraction;

	/* check bsp models */
	for (i = 0; i < refdef.numEntities; i++) {
		entity_t *ent = R_GetEntity(i);
		const model_t *m = ent->model;

		if (!m || m->type != mod_bsp_submodel)
			continue;

		tr = CM_TransformedBoxTrace(&(refdef.mapTiles->mapTiles[m->bsp.maptile]), start, end, mins, maxs, m->bsp.firstnode,
				contentmask, 0, ent->origin, ent->angles);

		if (tr.fraction < frac) {
			refdef.trace = tr;
			refdef.traceEntity = ent;

			frac = tr.fraction;
		}
	}

	assert(refdef.trace.mapTile >= 0);
	assert(refdef.trace.mapTile < r_numMapTiles);
}
开发者ID:ptitSeb,项目名称:UFO--AI-OpenPandora,代码行数:49,代码来源:r_lightmap.c

示例10: SV_ClipToEntity

/*
 * SV_ClipToEntity
 *
 */
void
SV_ClipToEntity(Trace *trace, const Vec3 start, const Vec3 mins,
		const Vec3 maxs, const Vec3 end, int entityNum,
		int contentmask,
		int capsule)
{
	Sharedent	*touch;
	Cliphandle	clipHandle;
	float *origin, *angles;

	touch = SV_GentityNum(entityNum);

	Q_Memset(trace, 0, sizeof(Trace));

	/* if it doesn't have any brushes of a type we
	 * are looking for, ignore it */
	if(!(contentmask & touch->r.contents)){
		trace->fraction = 1.0;
		return;
	}

	/* might intersect, so do an exact clip */
	clipHandle = SV_ClipHandleForEntity (touch);

	origin	= touch->r.currentOrigin;
	angles	= touch->r.currentAngles;

	if(!touch->r.bmodel)
		angles = vec3_origin;	/* boxes don't rotate */

	CM_TransformedBoxTrace (trace, (float*)start, (float*)end,
		(float*)mins, (float*)maxs, clipHandle,  contentmask,
		origin, angles, capsule);

	if(trace->fraction < 1)
		trace->entityNum = touch->s.number;
}
开发者ID:icanhas,项目名称:yantar,代码行数:41,代码来源:world.c

示例11: SV_ClipMoveToEntities

/*
=======================================================================================================================================
SV_ClipMoveToEntities
=======================================================================================================================================
*/
void SV_ClipMoveToEntities(moveclip_t *clip) {
	int i, num;
	int touchlist[MAX_GENTITIES];
	sharedEntity_t *touch;
	int passOwnerNum;
	trace_t trace;
	clipHandle_t clipHandle;
	float *origin, *angles;

	num = SV_AreaEntities(clip->boxmins, clip->boxmaxs, touchlist, MAX_GENTITIES);

	if (clip->passEntityNum != ENTITYNUM_NONE) {
		passOwnerNum = (SV_GentityNum(clip->passEntityNum))->r.ownerNum;

		if (passOwnerNum == ENTITYNUM_NONE) {
			passOwnerNum = -1;
		}
	} else {
		passOwnerNum = -1;
	}

	for (i = 0; i < num; i++) {
		if (clip->trace.allsolid) {
			return;
		}

		touch = SV_GentityNum(touchlist[i]);
		// see if we should ignore this entity
		if (clip->passEntityNum != ENTITYNUM_NONE) {
			if (touchlist[i] == clip->passEntityNum) {
				continue; // don't clip against the pass entity
			}

			if (touch->r.ownerNum == clip->passEntityNum) {
				continue; // don't clip against own missiles
			}

			if (touch->r.ownerNum == passOwnerNum) {
				continue; // don't clip against other missiles from our owner
			}
		}
		// if it doesn't have any brushes of a type we are looking for, ignore it
		if (!(clip->contentmask & touch->r.contents)) {
			continue;
		}
		// might intersect, so do an exact clip
		clipHandle = SV_ClipHandleForEntity(touch);
		// non-worldspawn entities must not use world as clip model!
		if (clipHandle == 0) {
			continue;
		}
		// if clipping against BBOX, set to correct contents
		if (clipHandle == BOX_MODEL_HANDLE) {
			CM_SetTempBoxModelContents(touch->r.contents);
		}

		origin = touch->r.currentOrigin;
		angles = touch->r.currentAngles;

		if (!touch->r.bmodel) {
			angles = vec3_origin; // boxes don't rotate
		}

		CM_TransformedBoxTrace(&trace, clip->start, clip->end, clip->mins, clip->maxs, clipHandle, clip->contentmask, origin, angles, clip->capsule);

		if (trace.allsolid) {
			clip->trace.allsolid = qtrue;
			trace.entityNum = touch->s.number;
		} else if (trace.startsolid) {
			clip->trace.startsolid = qtrue;
			trace.entityNum = touch->s.number;
		}

		if (trace.fraction < clip->trace.fraction) {
			// make sure we keep a startsolid from a previous trace
			qboolean oldStart = clip->trace.startsolid;

			trace.entityNum = touch->s.number;
			clip->trace = trace;
			clip->trace.startsolid |= oldStart;
		}
		// reset contents to default
		if (clipHandle == BOX_MODEL_HANDLE) {
			CM_SetTempBoxModelContents(CONTENTS_BODY);
		}
	}
}
开发者ID:ioid3-games,项目名称:ioid3-wet,代码行数:92,代码来源:sv_world.c

示例12: SV_ClipMoveToEntities

/*
====================
SV_ClipMoveToEntities

====================
*/
void SV_ClipMoveToEntities( moveclip_t *clip ) {
	int			i, num;
	int			touchlist[MAX_GENTITIES];
	sharedEntity_t *touch;
	int			passOwnerNum;
	trace_t		trace, oldTrace;
	clipHandle_t	clipHandle;
	float		*origin, *angles;
	int			thisOwnerShared = 1;

	num = SV_AreaEntities( clip->boxmins, clip->boxmaxs, touchlist, MAX_GENTITIES);

	if ( clip->passEntityNum != ENTITYNUM_NONE ) {
		passOwnerNum = ( SV_GentityNum( clip->passEntityNum ) )->r.ownerNum;
		if ( passOwnerNum == ENTITYNUM_NONE ) {
			passOwnerNum = -1;
		}
	} else {
		passOwnerNum = -1;
	}

	if ( SV_GentityNum(clip->passEntityNum)->r.svFlags & SVF_OWNERNOTSHARED )
	{
		thisOwnerShared = 0;
	}

	for ( i=0 ; i<num ; i++ ) {
		if ( clip->trace.allsolid ) {
			return;
		}
		touch = SV_GentityNum( touchlist[i] );

		// see if we should ignore this entity
		if ( clip->passEntityNum != ENTITYNUM_NONE ) {
			if ( touchlist[i] == clip->passEntityNum ) {
				continue;	// don't clip against the pass entity
			}
			if ( touch->r.ownerNum == clip->passEntityNum) {
				if (touch->r.svFlags & SVF_OWNERNOTSHARED)
				{
					if ( clip->contentmask != (MASK_SHOT | CONTENTS_LIGHTSABER) &&
						clip->contentmask != (MASK_SHOT))
					{ //it's not a laser hitting the other "missile", don't care then
						continue;
					}
				}
				else
				{
					continue;	// don't clip against own missiles
				}
			}
			if ( touch->r.ownerNum == passOwnerNum &&
				!(touch->r.svFlags & SVF_OWNERNOTSHARED) &&
				!thisOwnerShared ) {
				continue;	// don't clip against other missiles from our owner
			}
		}

		// if it doesn't have any brushes of a type we
		// are looking for, ignore it
		if ( ! ( clip->contentmask & touch->r.contents ) ) {
			continue;
		}

		if ((clip->contentmask == (MASK_SHOT|CONTENTS_LIGHTSABER) || clip->contentmask == MASK_SHOT) && (touch->r.contents > 0 && (touch->r.contents & CONTENTS_NOSHOT)))
		{
			continue;
		}

		// might intersect, so do an exact clip
		clipHandle = SV_ClipHandleForEntity (touch);

		origin = touch->r.currentOrigin;
		angles = touch->r.currentAngles;


		if ( !touch->r.bmodel ) {
			angles = vec3_origin;	// boxes don't rotate
		}

		CM_TransformedBoxTrace ( &trace, (float *)clip->start, (float *)clip->end,
			(float *)clip->mins, (float *)clip->maxs, clipHandle,  clip->contentmask,
			origin, angles, clip->capsule);

/*
Ghoul2 Insert Start
*/

		// keep these older variables around for a bit, incase we need to replace them in the Ghoul2 Collision check
		oldTrace = clip->trace;
/*
Ghoul2 Insert End
*/

//.........这里部分代码省略.........
开发者ID:5Quintessential,项目名称:jedioutcast,代码行数:101,代码来源:sv_world.cpp

示例13: SV_ClipMoveToEntity

__cdecl void SV_ClipMoveToEntity(moveclip_t *clip, svEntity_t *entity, trace_t *trace){

	gentity_t	*touch;
	int		touchNum;
	float		*origin, *angles;
	vec3_t		mins, maxs;
	float		oldfraction;
	clipHandle_t	clipHandle;

	touchNum = entity - sv.svEntities;

	touch = SV_GentityNum( touchNum );

	if( !(clip->contentmask & touch->r.contents))
		return;

	if ( clip->passEntityNum != ENTITYNUM_NONE ) {

		if( touchNum == clip->passEntityNum )
			return;

		if(touch->r.ownerNum){
		
			if( touch->r.ownerNum - 1 == clip->passEntityNum )
			    return;


			if( touch->r.ownerNum - 1 == clip->passOwnerNum )
			    return;
		
		}
		if(!G_ShouldEntitiesClip(clip, touchNum, touch))
			return;
	}

	VectorAdd(touch->r.absmin, clip->mins, mins);
	VectorAdd(touch->r.absmax, clip->maxs, maxs);

	if(CM_TraceBox(clip->extents.start, mins, maxs, trace->fraction))
		return;
	
	clipHandle = SV_ClipHandleForEntity(touch);

	origin = touch->r.currentOrigin;
	angles = touch->r.currentAngles;

	if ( !touch->r.bmodel ) {
		angles = vec3_origin;   // boxes don't rotate
	}

	oldfraction = trace->fraction;

	CM_TransformedBoxTrace( trace, clip->extents.start, clip->extents.end,
				clip->mins, clip->maxs, clipHandle, clip->contentmask, origin, angles );


	if ( trace->fraction < oldfraction ) {
		trace->var_02 = qtrue;
		trace->entityNum = touch->s.number;
	}

}
开发者ID:Call-of-Duty-Scripts,项目名称:CoD4x1.8_Server_Pub,代码行数:62,代码来源:sv_world.c

示例14: SV_ClipMoveToEntities

static void SV_ClipMoveToEntities(trace_t &trace, const CVec3 &start, const CVec3 &end, const CBox &bounds, edict_t *passedict, int contentmask)
{
	guard(SV_ClipMoveToEntities);

	if (trace.allsolid) return;

	int		i;

	CVec3 amins, amaxs;
	for (i = 0; i < 3; i++)
	{
		if (start[i] < end[i])
		{
			amins[i] = bounds.mins[i] + start[i];
			amaxs[i] = bounds.maxs[i] + end[i];
		}
		else
		{
			amins[i] = bounds.mins[i] + end[i];
			amaxs[i] = bounds.maxs[i] + start[i];
		}
	}
	edict_t	*list[MAX_EDICTS];
	int num = SV_AreaEdicts(amins, amaxs, ARRAY_ARG(list), AREA_SOLID);
	if (!num) return;

	float b1 = dot(bounds.mins, bounds.mins);
	float b2 = dot(bounds.maxs, bounds.maxs);
	float t = max(b1, b2);
	float traceWidth = SQRTFAST(t);
	CVec3 traceDir;
	VectorSubtract(end, start, traceDir);
	float traceLen = traceDir.Normalize() + traceWidth;

	for (i = 0; i < num; i++)
	{
		edict_t *edict = list[i];
		entityHull_t &ent = ents[NUM_FOR_EDICT(edict)];
//		if (!ent->linked) continue;

		if (edict->solid == SOLID_NOT || edict == passedict) continue;
		if (passedict)
		{
		 	if (edict->owner == passedict)
				continue;	// don't clip against own missiles
			if (passedict->owner == edict)
				continue;	// don't clip against owner
		}
		if (!(contentmask & CONTENTS_DEADMONSTER) && (edict->svflags & SVF_DEADMONSTER))
			continue;

		CVec3 eCenter;
		VectorSubtract(ent.center, start, eCenter);
		// check position of point projection on line
		float entPos = dot(eCenter, traceDir);
		if (entPos < -traceWidth - ent.radius || entPos > traceLen + ent.radius)
			continue;		// too near / too far

		// check distance between point and line
		CVec3 tmp;
		VectorMA(eCenter, -entPos, traceDir, tmp);
		float dist2 = dot(tmp, tmp);
		float dist0 = ent.radius + traceWidth;
		if (dist2 >= dist0 * dist0) continue;

		trace_t	tr;
		if (ent.model)
			CM_TransformedBoxTrace(tr, start, end, bounds, ent.model->headnode, contentmask, edict->s.origin, ent.axis);
		else
			CM_TransformedBoxTrace(tr, start, end, bounds, CM_HeadnodeForBox(ent.bounds), contentmask, edict->s.origin, nullVec3);
		if (CM_CombineTrace(trace, tr))
			trace.ent = edict;
		if (trace.allsolid) return;
	}

	unguard;
}
开发者ID:RkShaRkz,项目名称:Quake2,代码行数:77,代码来源:sv_world.cpp

示例15: SV_ClipMoveToEntities

static void SV_ClipMoveToEntities( moveclip_t *clip ) {
	int			i, num;
	int			touchlist[MAX_GENTITIES];
	sharedEntity_t *touch;
	int			passOwnerNum;
	trace_t		trace;
	clipHandle_t	clipHandle;
	vector3		*origin, *angles;

	num = SV_AreaEntities( &clip->boxmins, &clip->boxmaxs, touchlist, MAX_GENTITIES);

	if ( clip->passEntityNum != ENTITYNUM_NONE ) {
		passOwnerNum = ( SV_GentityNum( clip->passEntityNum ) )->r.ownerNum;
		if ( passOwnerNum == ENTITYNUM_NONE ) {
			passOwnerNum = -1;
		}
	} else {
		passOwnerNum = -1;
	}

	for ( i=0 ; i<num ; i++ ) {
		if ( clip->trace.allsolid ) {
			return;
		}
		touch = SV_GentityNum( touchlist[i] );

		// see if we should ignore this entity
		if ( clip->passEntityNum != ENTITYNUM_NONE ) {
			if ( touchlist[i] == clip->passEntityNum ) {
				continue;	// don't clip against the pass entity
			}
			//QTZTODO: Missiles colliding with eachother from https://github.com/dmead/jkaq3/commit/1d1e1fefb04fab8ceb42537702d946c1a75f4812
			if ( touch->r.ownerNum == clip->passEntityNum // don't clip against own missiles
				|| touch->r.ownerNum == passOwnerNum ) // don't clip against other missiles from our owner
				continue;
		}

		// if it doesn't have any brushes of a type we
		// are looking for, ignore it
		if ( ! ( clip->contentmask & touch->r.contents ) ) {
			continue;
		}

		// might intersect, so do an exact clip
		clipHandle = SV_ClipHandleForEntity (touch);

		origin = &touch->r.currentOrigin;
		angles = &touch->r.currentAngles;


		if ( !touch->r.bmodel ) {
			angles = &vec3_origin;	// boxes don't rotate
		}

		CM_TransformedBoxTrace( &trace, (vector3 *)clip->start, &clip->end, (vector3 *)clip->mins, (vector3 *)clip->maxs, clipHandle, clip->contentmask, origin, angles, clip->capsule );

		if ( trace.allsolid ) {
			clip->trace.allsolid = qtrue;
			trace.entityNum = touch->s.number;
		} else if ( trace.startsolid ) {
			clip->trace.startsolid = qtrue;
			trace.entityNum = touch->s.number;
		}

		if ( trace.fraction < clip->trace.fraction ) {
			qboolean	oldStart;

			// make sure we keep a startsolid from a previous trace
			oldStart = clip->trace.startsolid;

			trace.entityNum = touch->s.number;
			clip->trace = trace;
			clip->trace.startsolid |= oldStart;
		}
	}
}
开发者ID:Razish,项目名称:QtZ,代码行数:76,代码来源:sv_world.c


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