================ idCollisionModelManagerLocal::LoadRenderModel ================ */
| 3073 | ================ |
| 3074 | */ |
| 3075 | cm_model_t *idCollisionModelManagerLocal::LoadRenderModel( const char *fileName ) { |
| 3076 | int i, j; |
| 3077 | idRenderModel *renderModel; |
| 3078 | const modelSurface_t *surf; |
| 3079 | idFixedWinding w; |
| 3080 | cm_node_t *node; |
| 3081 | cm_model_t *model; |
| 3082 | idPlane plane; |
| 3083 | idBounds bounds; |
| 3084 | bool collisionSurface; |
| 3085 | idStr extension; |
| 3086 | |
| 3087 | // only load ASE and LWO models |
| 3088 | idStr( fileName ).ExtractFileExtension( extension ); |
| 3089 | if ( ( extension.Icmp( "ase" ) != 0 ) && ( extension.Icmp( "lwo" ) != 0 ) && ( extension.Icmp( "ma" ) != 0 ) ) { |
| 3090 | return NULL; |
| 3091 | } |
| 3092 | |
| 3093 | if ( !renderModelManager->CheckModel( fileName ) ) { |
| 3094 | return NULL; |
| 3095 | } |
| 3096 | |
| 3097 | renderModel = renderModelManager->FindModel( fileName ); |
| 3098 | |
| 3099 | model = AllocModel(); |
| 3100 | model->name = fileName; |
| 3101 | node = AllocNode( model, NODE_BLOCK_SIZE_SMALL ); |
| 3102 | node->planeType = -1; |
| 3103 | model->node = node; |
| 3104 | |
| 3105 | model->maxVertices = 0; |
| 3106 | model->numVertices = 0; |
| 3107 | model->maxEdges = 0; |
| 3108 | model->numEdges = 0; |
| 3109 | |
| 3110 | bounds = renderModel->Bounds( NULL ); |
| 3111 | |
| 3112 | collisionSurface = false; |
| 3113 | for ( i = 0; i < renderModel->NumSurfaces(); i++ ) { |
| 3114 | surf = renderModel->Surface( i ); |
| 3115 | if ( surf->shader->GetSurfaceFlags() & SURF_COLLISION ) { |
| 3116 | collisionSurface = true; |
| 3117 | } |
| 3118 | } |
| 3119 | |
| 3120 | for ( i = 0; i < renderModel->NumSurfaces(); i++ ) { |
| 3121 | surf = renderModel->Surface( i ); |
| 3122 | // if this surface has no contents |
| 3123 | if ( ! ( surf->shader->GetContentFlags() & CONTENTS_REMOVE_UTIL ) ) { |
| 3124 | continue; |
| 3125 | } |
| 3126 | // if the model has a collision surface and this surface is not a collision surface |
| 3127 | if ( collisionSurface && !( surf->shader->GetSurfaceFlags() & SURF_COLLISION ) ) { |
| 3128 | continue; |
| 3129 | } |
| 3130 | // get max verts and edges |
| 3131 | model->maxVertices += surf->geometry->numVerts; |
| 3132 | model->maxEdges += surf->geometry->numIndexes; |
nothing calls this directly
no test coverage detected