39 #define MIN_NODE_SIZE 64.0f
40 #define MAX_NODE_POLYGONS 128
41 #define CM_MAX_POLYGON_EDGES 64
42 #define CIRCLE_APPROXIMATION_LENGTH 64.0f
44 #define MAX_SUBMODELS 2048
45 #define TRACE_MODEL_HANDLE MAX_SUBMODELS
47 #define VERTEX_HASH_BOXSIZE (1<<6) // must be power of 2
48 #define VERTEX_HASH_SIZE (VERTEX_HASH_BOXSIZE*VERTEX_HASH_BOXSIZE)
49 #define EDGE_HASH_SIZE (1<<14)
51 #define NODE_BLOCK_SIZE_SMALL 8
52 #define NODE_BLOCK_SIZE_LARGE 256
53 #define REFERENCE_BLOCK_SIZE_SMALL 8
54 #define REFERENCE_BLOCK_SIZE_LARGE 256
56 #define MAX_WINDING_LIST 128 // quite a few are generated at times
57 #define INTEGRAL_EPSILON 0.01f
58 #define VERTEX_EPSILON 0.1f
59 #define CHOP_EPSILON 0.1f
90 unsigned short internal;
340 const idVec3 &viewOrigin,
const float radius );
364 const float minTan,
float &tanHalfAngle );
367 float &tanHalfAngle,
float &dir );
370 const float angle,
const float minTan,
float &tanHalfAngle );
372 const float angle,
float &tanHalfAngle,
float &dir );
374 const idPlane &plane,
const float angle,
const idVec3 &origin,
375 float &tanHalfAngle,
idVec3 &collisionPoint,
idVec3 &endDir );
382 const float startAngle,
const float endAngle,
const idVec3 &start,
498 const idVec3 &viewOrigin );
500 const idVec3 &viewOrigin,
const float radius );
void WriteCollisionModelsToFile(const char *filename, int firstModel, int lastModel, unsigned int mapFileCRC)
void SetupTrm(cm_traceWork_t *tw, const idTraceModel *trm)
int HashVec(const idVec3 &vec)
int CountPolygonMemory(cm_node_t *node) const
void RotateTrmEdgeThroughPolygon(cm_traceWork_t *tw, cm_polygon_t *poly, cm_trmEdge_t *trmEdge)
bool RotateTrmThroughPolygon(cm_traceWork_t *tw, cm_polygon_t *p)
struct cm_vertex_s cm_vertex_t
struct cm_node_s * children[2]
struct cm_trmVertex_s cm_trmVertex_t
void MergeTreePolygons(cm_model_t *model, cm_node_t *node)
cmHandle_t LoadModel(const char *modelName, const bool precache)
cm_nodeBlock_t * nodeBlocks
void cross(float a[], float b[], float c[])
bool MergePolygonWithTreePolygons(cm_model_t *model, cm_node_t *node, cm_polygon_t *polygon)
void Rotation180(trace_t *results, const idVec3 &rorg, const idVec3 &axis, const float startAngle, const float endAngle, const idVec3 &start, const idTraceModel *trm, const idMat3 &trmAxis, int contentMask, cmHandle_t model, const idVec3 &origin, const idMat3 &modelAxis)
struct cm_trmPolygon_s cm_trmPolygon_t
void FreeBrushReference(cm_brushRef_t *bref)
void FreePolygonReference(cm_polygonRef_t *pref)
void TranslateVertexThroughTrmPolygon(cm_traceWork_t *tw, cm_trmPolygon_t *trmpoly, cm_polygon_t *poly, cm_vertex_t *v, idVec3 &endp, idPluecker &pl)
void TranslateTrmEdgeThroughPolygon(cm_traceWork_t *tw, cm_polygon_t *poly, cm_trmEdge_t *trmEdge)
cmHandle_t SetupTrmModel(const idTraceModel &trm, const idMaterial *material)
void FindInternalEdges(cm_model_t *model, cm_node_t *node)
void FreePolygon(cm_model_t *model, cm_polygon_t *poly)
void Translation(trace_t *results, const idVec3 &start, const idVec3 &end, const idTraceModel *trm, const idMat3 &trmAxis, int contentMask, cmHandle_t model, const idVec3 &modelOrigin, const idMat3 &modelAxis)
idPluecker polygonEdgePlueckerCache[CM_MAX_POLYGON_EDGES]
const char * StringFromContents(const int contents) const
struct cm_trmEdge_s cm_trmEdge_t
void RemoveBrushReferences_r(cm_node_t *node, cm_brush_t *b)
void WriteBrushes(idFile *fp, cm_node_t *node)
void ConvertBrushSides(cm_model_t *model, const idMapBrush *mapBrush, int primitiveNum)
cm_polygon_t * AllocPolygon(cm_model_t *model, int numEdges)
bool TestTrmVertsInBrush(cm_traceWork_t *tw, cm_brush_t *b)
const char * GetModelName(cmHandle_t model) const
struct cm_nodeBlock_s cm_nodeBlock_t
struct cm_nodeBlock_s * next
int Contacts(contactInfo_t *contacts, const int maxContacts, const idVec3 &start, const idVec6 &dir, const float depth, const idTraceModel *trm, const idMat3 &trmAxis, int contentMask, cmHandle_t model, const idVec3 &modelOrigin, const idMat3 &modelAxis)
struct cm_polygonRef_s * next
void ModelInfo(cmHandle_t model)
void RemovePolygonReferences_r(cm_node_t *node, cm_polygon_t *p)
void ParsePolygons(idLexer *src, cm_model_t *model)
int PointContents(const idVec3 p, cmHandle_t model)
const idMaterial * trmMaterial
GLint GLint GLsizei GLsizei GLsizei depth
const idMaterial * material
int CountBrushMemory(cm_node_t *node) const
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)
void FreeBrush(cm_model_t *model, cm_brush_t *brush)
cm_brushRefBlock_t * brushRefBlocks
cm_procNode_t * procNodes
void RecurseProcBSP_r(trace_t *results, int parentNodeNum, int nodeNum, float p1f, float p2f, const idVec3 &p1, const idVec3 &p2)
cm_polygonRef_t * trmPolygons[MAX_TRACEMODEL_POLYS]
void DrawEdge(cm_model_t *model, int edgeNum, const idVec3 &origin, const idMat3 &axis)
struct cm_traceWork_s cm_traceWork_t
void PrintModelInfo(const cm_model_t *model)
void WriteNodes(idFile *fp, cm_node_t *node)
void R_FilterPolygonIntoTree(cm_model_t *model, cm_node_t *node, cm_polygonRef_t *pref, cm_polygon_t *p)
cm_polygonRef_t * nextRef
bool PointInsidePolygon(cm_model_t *model, cm_polygon_t *p, idVec3 &v)
idRotation modelVertexRotation
void TranslatePointThroughPolygon(cm_traceWork_t *tw, cm_polygon_t *poly, cm_trmVertex_t *v)
void LoadProcBSP(const char *name)
void ReplacePolygons(cm_model_t *model, cm_node_t *node, cm_polygon_t *p1, cm_polygon_t *p2, cm_polygon_t *newp)
int GetVertex(cm_model_t *model, const idVec3 &v, int *vertexNum)
#define MAX_TRACEMODEL_POLYS
int R_ChoppedAwayByProcBSP(int nodeNum, idFixedWinding *w, const idVec3 &normal, const idVec3 &origin, const float radius)
void AccumulateModelInfo(cm_model_t *model)
GLfloat GLfloat GLfloat v2
struct cm_model_s cm_model_t
void SetupTranslationHeartPlanes(cm_traceWork_t *tw)
bool LoadCollisionModelFile(const char *name, unsigned int mapFileCRC)
void TraceThroughAxialBSPTree_r(cm_traceWork_t *tw, cm_node_t *node, float p1f, float p2f, idVec3 &p1, idVec3 &p2)
struct cm_procNode_s cm_procNode_t
struct cm_polygonBlock_s cm_polygonBlock_t
cm_model_t * AllocModel(void)
void FreeTree_r(cm_model_t *model, cm_node_t *headNode, cm_node_t *node)
void FinishModel(cm_model_t *model)
GLubyte GLubyte GLubyte GLubyte w
struct cm_polygonRef_s cm_polygonRef_t
int TranslateEdgeThroughEdge(idVec3 &cross, idPluecker &l1, idPluecker &l2, float *fraction)
void ConvertPatch(cm_model_t *model, const idMapPatch *patch, int primitiveNum)
const idMaterial * material
bool GetModelPolygon(cmHandle_t model, int polygonNum, idFixedWinding &winding) const
void BoundsForRotation(const idVec3 &origin, const idVec3 &axis, const idVec3 &start, const idVec3 &end, idBounds &bounds)
cm_polygon_t * TryMergePolygons(cm_model_t *model, cm_polygon_t *p1, cm_polygon_t *p2)
void Rotation(trace_t *results, const idVec3 &start, const idRotation &rotation, const idTraceModel *trm, const idMat3 &trmAxis, int contentMask, cmHandle_t model, const idVec3 &modelOrigin, const idMat3 &modelAxis)
cm_brushBlock_t * brushBlock
int TransformedPointContents(const idVec3 &p, cmHandle_t model, const idVec3 &origin, const idMat3 &modelAxis)
idFixedWinding * WindingOutsideBrushes(idFixedWinding *w, const idPlane &plane, int contents, int patch, cm_node_t *headNode)
int ChoppedAwayByProcBSP(const idFixedWinding &w, const idPlane &plane, int contents)
cm_trmEdge_t edges[MAX_TRACEMODEL_EDGES+1]
void TraceThroughModel(cm_traceWork_t *tw)
void R_FilterBrushIntoTree(cm_model_t *model, cm_node_t *node, cm_brushRef_t *pref, cm_brush_t *b)
void ParseEdges(idLexer *src, cm_model_t *model)
cm_polygonRef_t * AllocPolygonReference(cm_model_t *model, int blockSize)
void FreeModel(cm_model_t *model)
cm_node_t * R_CreateAxialBSPTree(cm_model_t *model, cm_node_t *node, const idBounds &bounds)
struct cm_polygonRefBlock_s * next
void TraceTrmThroughNode(cm_traceWork_t *tw, cm_node_t *node)
cm_polygonBlock_t * polygonBlock
struct cm_brushBlock_s cm_brushBlock_t
struct cm_brush_s cm_brush_t
void AddBrushToNode(cm_model_t *model, cm_node_t *node, cm_brush_t *b)
int GetEdge(cm_model_t *model, const idVec3 &v1, const idVec3 &v2, int *edgeNum, int v1num)
void CalculateEdgeNormals(cm_model_t *model, cm_node_t *node)
void FindInternalEdgesOnPolygon(cm_model_t *model, cm_polygon_t *p1, cm_polygon_t *p2)
#define CM_MAX_POLYGON_EDGES
int RotatePointThroughPlane(const cm_traceWork_t *tw, const idVec3 &point, const idPlane &plane, const float angle, const float minTan, float &tanHalfAngle)
void RemapEdges(cm_node_t *node, int *edgeRemap)
bool TestTrmInPolygon(cm_traceWork_t *tw, cm_polygon_t *p)
void RotateTrmVertexThroughPolygon(cm_traceWork_t *tw, cm_polygon_t *poly, cm_trmVertex_t *v, int vertexNum)
void FindInternalPolygonEdges(cm_model_t *model, cm_node_t *node, cm_polygon_t *polygon)
void FreeNode(cm_node_t *node)
cm_node_t * AllocNode(cm_model_t *model, int blockSize)
void CreatePolygon(cm_model_t *model, idFixedWinding *w, const idPlane &plane, const idMaterial *material, int primitiveNum)
void SetupTrmModelStructure(void)
int EdgeFurthestFromEdge(cm_traceWork_t *tw, const idPluecker &pl1, const idVec3 &vc, const idVec3 &vd, float &tanHalfAngle, float &dir)
void ParseVertices(idLexer *src, cm_model_t *model)
void WritePolygons(idFile *fp, cm_node_t *node)
void DebugOutput(const idVec3 &origin)
void DrawPolygon(cm_model_t *model, cm_polygon_t *p, const idVec3 &origin, const idMat3 &axis, const idVec3 &viewOrigin)
bool GetModelBounds(cmHandle_t model, idBounds &bounds) const
struct cm_polygon_s cm_polygon_t
idVec3 polygonRotationOriginCache[CM_MAX_POLYGON_EDGES]
void AddPolygonToNode(cm_model_t *model, cm_node_t *node, cm_polygon_t *p)
bool WriteCollisionModelForMapEntity(const idMapEntity *mapEnt, const char *filename, const bool testTraceModel=true)
void RotateVertexThroughTrmPolygon(cm_traceWork_t *tw, cm_trmPolygon_t *trmpoly, cm_polygon_t *poly, cm_vertex_t *v, idVec3 &rotationOrigin)
#define MAX_TRACEMODEL_EDGES
int ContentsFromString(const char *string) const
void TranslateTrmVertexThroughPolygon(cm_traceWork_t *tw, cm_polygon_t *poly, cm_trmVertex_t *v, int bitNum)
cmHandle_t FindModel(const char *name)
bool GetModelEdge(cmHandle_t model, int edgeNum, idVec3 &start, idVec3 &end) const
void DrawNodePolygons(cm_model_t *model, cm_node_t *node, const idVec3 &origin, const idMat3 &axis, const idVec3 &viewOrigin, const float radius)
cm_model_t * CollisionModelForMapEntity(const idMapEntity *mapEnt)
void R_ChopWindingListWithTreeBrushes(cm_windingList_t *list, cm_node_t *node)
void FreeTrmModelStructure(void)
void WriteCollisionModel(idFile *fp, cm_model_t *model)
struct cm_brushRefBlock_s * next
cm_brushRef_t * AllocBrushReference(cm_model_t *model, int blockSize)
bool ParseCollisionModel(idLexer *src)
void PolygonFromWinding(cm_model_t *model, idFixedWinding *w, const idPlane &plane, const idMaterial *material, int primitiveNum)
bool TrmFromModel_r(idTraceModel &trm, cm_node_t *node)
void FindContainedEdges(cm_model_t *model, cm_polygon_t *p)
struct cm_node_s cm_node_t
struct cm_node_s * parent
bool GetModelVertex(cmHandle_t model, int vertexNum, idVec3 &vertex) const
struct cm_brushRef_s * next
void OptimizeArrays(cm_model_t *model)
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]
struct cm_brushRefBlock_s cm_brushRefBlock_t
#define MAX_TRACEMODEL_VERTS
idPluecker polygonVertexPlueckerCache[CM_MAX_POLYGON_EDGES]
void DrawModel(cmHandle_t model, const idVec3 &origin, const idMat3 &axis, const idVec3 &viewOrigin, const float radius)
struct cm_polygonRefBlock_s cm_polygonRefBlock_t
struct cm_edge_s cm_edge_t
void ChopWindingListWithBrush(cm_windingList_t *list, cm_brush_t *b)
struct cm_brushRef_s cm_brushRef_t
void CreatePatchPolygons(cm_model_t *model, idSurface_Patch &mesh, const idMaterial *material, int primitiveNum)
void ParseBrushes(idLexer *src, cm_model_t *model)
#define MAX_TRACEMODEL_POLYEDGES
bool TrmFromModel(const char *modelName, idTraceModel &trm)
char * va(const char *fmt,...)
void ConvertBrush(cm_model_t *model, const idMapBrush *mapBrush, int primitiveNum)
cm_trmPolygon_t polys[MAX_TRACEMODEL_POLYS]
cm_polygonRef_t * polygons
cm_polygonRefBlock_t * polygonRefBlocks
void LoadMap(const idMapFile *mapFile)
int CollisionBetweenEdgeBounds(cm_traceWork_t *tw, const idVec3 &va, const idVec3 &vb, const idVec3 &vc, const idVec3 &vd, float tanHalfAngle, idVec3 &collisionPoint, idVec3 &collisionNormal)
cm_node_t * CreateAxialBSPTree(cm_model_t *model, cm_node_t *node)
int RotatePointThroughEpsilonPlane(const cm_traceWork_t *tw, const idVec3 &point, const idVec3 &endPoint, const idPlane &plane, const float angle, const idVec3 &origin, float &tanHalfAngle, idVec3 &collisionPoint, idVec3 &endDir)
void ClearHash(idBounds &bounds)
cm_node_t * PointNode(const idVec3 &p, cm_model_t *model)
int RotateEdgeThroughEdge(cm_traceWork_t *tw, const idPluecker &pl1, const idVec3 &vc, const idVec3 &vd, const float minTan, float &tanHalfAngle)
int PointFurthestFromPlane(const cm_traceWork_t *tw, const idVec3 &point, const idPlane &plane, const float angle, float &tanHalfAngle, float &dir)
cm_model_t * LoadRenderModel(const char *fileName)
bool GetModelContents(cmHandle_t model, int &contents) const
void BuildModels(const idMapFile *mapFile)
cm_node_t * ParseNodes(idLexer *src, cm_model_t *model, cm_node_t *parent)
float maxDistFromHeartPlane2
struct cm_windingList_s cm_windingList_t
bool TranslateTrmThroughPolygon(cm_traceWork_t *tw, cm_polygon_t *p)
cm_trmVertex_t vertices[MAX_TRACEMODEL_VERTS]
void ParseProcNodes(idLexer *src)
float maxDistFromHeartPlane1
cm_brushRef_t * trmBrushes[1]
cm_brush_t * AllocBrush(cm_model_t *model, int numPlanes)