37 #include "../idlib/precompiled.h"
42 #define CM_FILE_EXT "cm"
43 #define CM_FILEID "CM"
44 #define CM_FILEVERSION "1.00"
109 for ( pref = node->
polygons; pref; pref = pref->
next ) {
116 for ( i = 0; i < p->
numEdges; i++ ) {
141 for ( bref = node->
brushes; bref; bref = bref->
next ) {
167 for ( bref = node->
brushes; bref; bref = bref->
next ) {
192 int i, polygonMemory, brushMemory;
203 for ( i = 0; i < model->
numEdges; i++ ) {
214 fp->
WriteFloatString(
"\tpolygons /* polygonMemory = */ %d {\n", polygonMemory );
221 fp->
WriteFloatString(
"\tbrushes /* brushMemory = */ %d {\n", brushMemory );
246 common->
Warning(
"idCollisionModelManagerLocal::WriteCollisionModelsToFile: Error opening file %s\n", name.
c_str() );
256 for ( i = firstModel; i < lastModel; i++ ) {
275 model->
name = filename;
283 common->
Printf(
"idCollisionModelManagerLocal::WriteCollisionModelForMapEntity: Error opening file %s\n", name.
c_str() );
298 if ( testTraceModel ) {
350 for ( i = 0; i < model->
numEdges; i++ ) {
414 for ( i = 0; i < p->
numEdges; i++ ) {
502 if ( token ==
"vertices" ) {
507 if ( token ==
"edges" ) {
512 if ( token ==
"nodes" ) {
519 if ( token ==
"polygons" ) {
524 if ( token ==
"brushes" ) {
529 src->
Error(
"ParseCollisionModel: bad token \"%s\"", token.
c_str() );
590 if ( mapFileCRC && crc != mapFileCRC ) {
602 if ( token ==
"collisionModel" ) {
610 src->
Error(
"idCollisionModelManagerLocal::LoadCollisionModelFile: bad token \"%s\"", token.
c_str() );
void WriteCollisionModelsToFile(const char *filename, int firstModel, int lastModel, unsigned int mapFileCRC)
int CheckTokenString(const char *string)
int CountPolygonMemory(cm_node_t *node) const
struct cm_vertex_s cm_vertex_t
struct cm_node_s * children[2]
idStr & SetFileExtension(const char *extension)
const idVec3 & Normal(void) const
const float * ToFloatPtr(void) const
int Parse1DMatrix(int x, float *m)
const char * StringFromContents(const int contents) const
void WriteBrushes(idFile *fp, cm_node_t *node)
idFileSystem * fileSystem
cm_polygon_t * AllocPolygon(cm_model_t *model, int numEdges)
unsigned long GetUnsignedLongValue(void)
struct cm_polygonRef_s * next
void ParsePolygons(idLexer *src, cm_model_t *model)
const char * GetName(void) const
const idMaterial * material
int CheckTokenType(int type, int subtype, idToken *token)
int CountBrushMemory(cm_node_t *node) const
virtual const idMaterial * FindMaterial(const char *name, bool makeDefault=true)=0
float ParseFloat(bool *errorFlag=NULL)
void SetNormal(const idVec3 &normal)
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)
void CM_GetNodeBounds(idBounds *bounds, cm_node_t *node)
void Error(const char *str,...) id_attribute((format(printf
bool LoadCollisionModelFile(const char *name, unsigned int mapFileCRC)
int ExpectTokenType(int type, int subtype, idToken *token)
struct cm_polygonBlock_s cm_polygonBlock_t
cm_model_t * AllocModel(void)
#define NODE_BLOCK_SIZE_LARGE
void SetDist(const float dist)
idVec3 vec3_origin(0.0f, 0.0f, 0.0f)
cm_brushBlock_t * brushBlock
void R_FilterBrushIntoTree(cm_model_t *model, cm_node_t *node, cm_brushRef_t *pref, cm_brush_t *b)
const int GetContentFlags(void) const
void ParseEdges(idLexer *src, cm_model_t *model)
void FreeModel(cm_model_t *model)
virtual idFile * OpenFileWrite(const char *relativePath, const char *basePath="fs_savepath")=0
cm_polygonBlock_t * polygonBlock
struct cm_brushBlock_s cm_brushBlock_t
struct cm_brush_s cm_brush_t
void CalculateEdgeNormals(cm_model_t *model, cm_node_t *node)
virtual int WriteFloatString(const char *fmt,...) id_attribute((format(printf
virtual void Printf(const char *fmt,...) id_attribute((format(printf
#define NODE_BLOCK_SIZE_SMALL
cm_node_t * AllocNode(cm_model_t *model, int blockSize)
idDeclManager * declManager
void ParseVertices(idLexer *src, cm_model_t *model)
void WritePolygons(idFile *fp, cm_node_t *node)
struct cm_polygon_s cm_polygon_t
bool WriteCollisionModelForMapEntity(const idMapEntity *mapEnt, const char *filename, const bool testTraceModel=true)
int ExpectTokenString(const char *string)
int CM_GetNodeContents(cm_node_t *node)
int ContentsFromString(const char *string) const
cm_model_t * CollisionModelForMapEntity(const idMapEntity *mapEnt)
void WriteCollisionModel(idFile *fp, cm_model_t *model)
bool ParseCollisionModel(idLexer *src)
struct cm_node_s cm_node_t
struct cm_node_s * parent
struct cm_brushRef_s * next
const char * c_str(void) const
void * Mem_Alloc(const int size)
struct cm_brushRef_s cm_brushRef_t
void ParseBrushes(idLexer *src, cm_model_t *model)
bool TrmFromModel(const char *modelName, idTraceModel &trm)
virtual void CloseFile(idFile *f)=0
cm_polygonRef_t * polygons
virtual void Error(const char *fmt,...) id_attribute((format(printf
virtual void virtual void Warning(const char *fmt,...) id_attribute((format(printf
int ReadToken(idToken *token)
cm_node_t * ParseNodes(idLexer *src, cm_model_t *model, cm_node_t *parent)
cm_brush_t * AllocBrush(cm_model_t *model, int numPlanes)