37 #include "../idlib/precompiled.h"
58 int i,
j, numVerts, bestPlane;
83 for ( j = 0; j < numVerts; j++ ) {
120 #define CM_SetTrmEdgeSidedness( edge, bpl, epl, bitNum ) { \
121 if ( !(edge->sideSet & (1<<bitNum)) ) { \
123 fl = (bpl).PermutedInnerProduct( epl ); \
124 edge->side = (edge->side & ~(1<<bitNum)) | (FLOATSIGNBITSET(fl) << bitNum); \
125 edge->sideSet |= (1 << bitNum); \
134 #define CM_SetTrmPolygonSidedness( v, plane, bitNum ) { \
135 if ( !((v)->sideSet & (1<<bitNum)) ) { \
137 fl = plane.Distance( (v)->p ); \
140 (v)->side |= (1 << bitNum); \
143 (v)->side &= ~(1 << bitNum); \
145 (v)->sideSet |= (1 << bitNum); \
157 int i,
j, k, edgeNum, flip, trmEdgeNum, bitNum, bestPlane;
196 for ( i = 0; i < p->
numEdges; i++ ) {
204 for ( j = 0; j < 2; j++ ) {
213 for ( k = 0; k < tw->
numPolys; k++ ) {
239 for ( i = 0; i < p->
numEdges; i++ ) {
258 for ( i = 0; i < tw->
numVerts; i++ ) {
260 sides[
i] = d < 0.0f ? -1 : 1;
264 for ( i = 1; i <= tw->
numEdges; i++ ) {
272 for ( j = 0; j < p->
numEdges; j++ ) {
312 for ( i = 0; i < p->
numEdges; i++ ) {
320 for ( j = 0; j < tw->
numPolys; j++ ) {
327 if ( !(((v1->
side ^ v2->
side) >> j) & 1) ) {
330 flip = (v1->
side >>
j) & 1;
339 if ( (d1 >= 0.0
f && d2 >= 0.0
f) || (d1 <= 0.0
f && d2 <= 0.0
f) ) {
350 trmEdge = tw->
edges + abs(trmEdgeNum);
352 bitNum = abs(trmEdgeNum);
362 if ( trmEdgeNum > 0 ) {
427 for ( bref = node->
brushes; bref; bref = bref->
next ) {
430 for ( i = 0; i < 3; i++ ) {
431 if ( p[i] < b->
bounds[0][i] ) {
434 if ( p[i] > b->
bounds[1][i] ) {
443 for ( i = 0; i < b->
numPlanes; i++, plane++ ) {
482 bool model_rotated, trm_rotated;
483 idMat3 invModelAxis, tmpAxis;
488 if ( !trm || ( trm->
bounds[1][0] - trm->
bounds[0][0] <= 0.0f &&
513 tw.
start = start - modelOrigin;
517 if ( model_rotated ) {
528 for ( i = 0; i < tw.
numVerts; i++ ) {
533 for ( i = 0; i < tw.
numVerts; i++ ) {
537 if ( model_rotated ) {
538 for ( i = 0; i < tw.
numVerts; i++ ) {
546 dir = trm->
offset * trmAxis;
553 if ( model_rotated ) {
555 tw.
start *= invModelAxis;
556 tw.
end *= invModelAxis;
562 for ( i = 0; i < tw.
numVerts; i++ ) {
568 for ( i = 1; i <= tw.
numEdges; i++ ) {
576 if ( trm_rotated & model_rotated ) {
577 tmpAxis = trmAxis * invModelAxis;
578 for ( i = 0; i < tw.
numPolys; i++ ) {
581 }
else if ( trm_rotated ) {
582 for ( i = 0; i < tw.
numPolys; i++ ) {
585 }
else if ( model_rotated ) {
586 for ( i = 0; i < tw.
numPolys; i++ ) {
590 for ( i = 0; i < tw.
numPolys; i++ ) {
595 for ( i = 0; i < 3; i++ ) {
632 common->
Printf(
"idCollisionModelManagerLocal::Contents: invalid model handle\n");
636 common->
Printf(
"idCollisionModelManagerLocal::Contents: invalid model\n");
640 return ContentsTrm( &results, start, trm, trmAxis, contentMask, model, modelOrigin, modelAxis );
void SetupTrm(cm_traceWork_t *tw, const idTraceModel *trm)
struct cm_node_s * children[2]
static const float INFINITY
assert(prefInfo.fullscreenBtn)
const idVec3 & Normal(void) const
idMat3 Transpose(void) const
float Distance(const idVec3 &v) const
idPluecker polygonEdgePlueckerCache[CM_MAX_POLYGON_EDGES]
bool TestTrmVertsInBrush(cm_traceWork_t *tw, cm_brush_t *b)
int PointContents(const idVec3 p, cmHandle_t model)
const idMaterial * material
int ContentsTrm(trace_t *results, const idVec3 &start, const idTraceModel *trm, const idMat3 &trmAxis, int contentMask, cmHandle_t model, const idVec3 &modelOrigin, const idMat3 &modelAxis)
bool IsRotated(void) const
void FromLine(const idVec3 &start, const idVec3 &end)
bool AddPoint(const idVec3 &v)
GLfloat GLfloat GLfloat v2
const idMaterial * material
int TransformedPointContents(const idVec3 &p, cmHandle_t model, const idVec3 &origin, const idMat3 &modelAxis)
cm_trmEdge_t edges[MAX_TRACEMODEL_EDGES+1]
static float Fabs(float f)
void TraceThroughModel(cm_traceWork_t *tw)
float PermutedInnerProduct(const idPluecker &a) const
bool TestTrmInPolygon(cm_traceWork_t *tw, cm_polygon_t *p)
virtual void Printf(const char *fmt,...) id_attribute((format(printf
#define CM_SetTrmEdgeSidedness(edge, bpl, epl, bitNum)
#define CM_SetTrmPolygonSidedness(v, plane, bitNum)
bool IntersectsBounds(const idBounds &a) const
struct cm_brushRef_s * next
int Contents(const idVec3 &start, const idTraceModel *trm, const idMat3 &trmAxis, int contentMask, cmHandle_t model, const idVec3 &modelOrigin, const idMat3 &modelAxis)
int edges[MAX_TRACEMODEL_POLYEDGES]
#define MAX_TRACEMODEL_VERTS
cm_trmPolygon_t polys[MAX_TRACEMODEL_POLYS]
int PlaneSide(const idPlane &plane, const float epsilon=ON_EPSILON) const
cm_node_t * PointNode(const idVec3 &p, cm_model_t *model)
cm_trmVertex_t vertices[MAX_TRACEMODEL_VERTS]
void FitThroughPoint(const idVec3 &p)