| 1336 | } |
| 1337 | |
| 1338 | void MapDrawerSoft::DrawModel( |
| 1339 | const ModelsGroup& models_group, |
| 1340 | const std::vector<Model>& model_group_models, |
| 1341 | const unsigned int model_id, |
| 1342 | const unsigned int animation_frame, |
| 1343 | const ViewClipPlanes& view_clip_planes, |
| 1344 | const m_Vec3& position, |
| 1345 | const m_Mat4& rotation_matrix, |
| 1346 | const m_Mat4& view_matrix, |
| 1347 | const m_Vec3& camera_position, |
| 1348 | const unsigned char visible_groups_mask, |
| 1349 | const bool transparent, |
| 1350 | const bool force_transparent_nontransparent_polygons, |
| 1351 | const bool fullbright, |
| 1352 | const unsigned int submodel_id, |
| 1353 | const unsigned char color ) |
| 1354 | { |
| 1355 | const Model& base_model= model_group_models[ model_id ]; |
| 1356 | const Submodel& model= (submodel_id == ~0u) ? base_model : base_model.submodels[ submodel_id ]; |
| 1357 | const std::vector<unsigned short>& indeces= transparent ? model.transparent_triangles_indeces : model.regular_triangles_indeces; |
| 1358 | if( indeces.size() == 0u ) |
| 1359 | return; |
| 1360 | |
| 1361 | unsigned int active_clip_planes_mask= 0u; |
| 1362 | |
| 1363 | PC_ASSERT( animation_frame < model.frame_count ); |
| 1364 | const m_BBox3& bbox= model.animations_bboxes[ animation_frame ]; |
| 1365 | |
| 1366 | m_Mat4 translate_mat, bbox_mat; |
| 1367 | translate_mat.Translate( position ); |
| 1368 | bbox_mat= rotation_matrix * translate_mat; |
| 1369 | |
| 1370 | // Clip-planes bounding box test |
| 1371 | for( const m_Plane3& clip_plane : view_clip_planes ) |
| 1372 | { |
| 1373 | unsigned int vertices_inside= 0u; |
| 1374 | for( unsigned int z= 0u; z < 2u; z++ ) |
| 1375 | for( unsigned int y= 0u; y < 2u; y++ ) |
| 1376 | for( unsigned int x= 0u; x < 2u; x++ ) |
| 1377 | { |
| 1378 | const m_Vec3 point( |
| 1379 | x == 0 ? bbox.min.x : bbox.max.x, |
| 1380 | y == 0 ? bbox.min.y : bbox.max.y, |
| 1381 | z == 0 ? bbox.min.z : bbox.max.z ); |
| 1382 | |
| 1383 | if( clip_plane.IsPointAheadPlane( point * bbox_mat ) ) |
| 1384 | vertices_inside++; |
| 1385 | } |
| 1386 | |
| 1387 | if( vertices_inside == 0u ) |
| 1388 | return; // Discard model - it is fully outside view |
| 1389 | |
| 1390 | if( vertices_inside != 8u ) |
| 1391 | active_clip_planes_mask|= 1u << ( &clip_plane - &view_clip_planes[0] ); |
| 1392 | } // For clip planes |
| 1393 | |
| 1394 | // Transform clip planes into model space. |
| 1395 | ViewClipPlanes clip_planes_transformed; |
nothing calls this directly
no test coverage detected