int CM_PointLeafnum(const vec3_t p) { if (!cm.numNodes) // map not loaded { return 0; } return CM_PointLeafnum_r(p, 0); }
/* ================== CM_PointContents ================== */ int CM_PointContents(const vec3_t p, clipHandle_t model) { int leafnum; int i, k; int brushnum; cLeaf_t *leaf; cbrush_t *b; int contents; float d; cmodel_t *clipm; if(!cm.numNodes) // map not loaded { return 0; } if(model) { clipm = CM_ClipHandleToModel(model); leaf = &clipm->leaf; } else { leafnum = CM_PointLeafnum_r(p, 0); leaf = &cm.leafs[leafnum]; } contents = 0; for(k = 0 ; k < leaf->numLeafBrushes ; k++) { brushnum = cm.leafbrushes[leaf->firstLeafBrush + k]; b = &cm.brushes[brushnum]; // see if the point is in the brush for(i = 0 ; i < b->numsides ; i++) { d = DotProduct(p, b->sides[i].plane->normal); // FIXME test for Cash // if ( d >= b->sides[i].plane->dist ) { if(d > b->sides[i].plane->dist) { break; } } if(i == b->numsides) { contents |= b->contents; } } return contents; }
/* ================== CM_PointContents ================== */ int CM_PointContents( const vec3_t p, clipHandle_t model ) { int leafnum; int i, k; int brushnum; cLeaf_t *leaf; cbrush_t *b; int contents; float d; cmodel_t *clipm; if ( !cm.numNodes ) { // map not loaded return 0; } if ( model ) { clipm = CM_ClipHandleToModel( model ); leaf = &clipm->leaf; } else { leafnum = CM_PointLeafnum_r( p, 0 ); leaf = &cm.leafs[ leafnum ]; } // XreaL BEGIN if ( leaf->area == -1 ) { // RB: added this optimization // p is in the void and we should return solid so particles can be removed from the void return CONTENTS_SOLID; } // XreaL END contents = 0; for ( k = 0; k < leaf->numLeafBrushes; k++ ) { brushnum = cm.leafbrushes[ leaf->firstLeafBrush + k ]; b = &cm.brushes[ brushnum ]; // XreaL BEGIN if ( !CM_BoundsIntersectPoint( b->bounds[ 0 ], b->bounds[ 1 ], p ) ) { continue; } // XreaL END // see if the point is in the brush for ( i = 0; i < b->numsides; i++ ) { d = DotProduct( p, b->sides[ i ].plane->normal ); // FIXME test for Cash // if ( d >= b->sides[i].plane->dist ) { if ( d > b->sides[ i ].plane->dist ) { break; } } if ( i == b->numsides ) { contents |= b->contents; } } return contents; }