MCPcopy Create free account
hub / github.com/Panzerschrek/Chasm-Reverse / DrawMapModelsShadows

Method DrawMapModelsShadows

PanzerChasm/client/map_drawer_gl.cpp:2204–2262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2202
2203
2204void MapDrawerGL::DrawMapModelsShadows(
2205 const MapState& map_state,
2206 const m_Mat4& view_matrix,
2207 const ViewClipPlanes& view_clip_planes )
2208{
2209 PC_UNUSED(view_clip_planes);
2210
2211 models_geometry_data_.Bind();
2212 models_shadow_shader_.Bind();
2213
2214 models_animations_.Bind( 0 );
2215 models_shadow_shader_.Uniform( "animations_vertices_buffer", int(0) );
2216
2217 models_shadow_shader_.Uniform( "enabled_groups_mask", int(255) );
2218
2219 const bool transparent= false;
2220 for( const MapState::StaticModel& static_model : map_state.GetStaticModels() )
2221 {
2222 if( static_model.model_id >= models_geometry_.size() ||
2223 !static_model.visible )
2224 continue;
2225
2226 const MapData::ModelDescription& description= current_map_data_->models_description[ static_model.model_id ];
2227 if( !description.cast_shadow )
2228 continue;
2229
2230 m_Vec3 light_pos;
2231 if( !GetNearestLightSourcePos( static_model.pos, *current_map_data_, map_state, false, light_pos ) )
2232 continue;
2233
2234 const ModelGeometry& model_geometry= models_geometry_[ static_model.model_id ];
2235 // const Model& model= current_map_data_->models[ static_model.model_id ];
2236
2237 const unsigned int index_count= transparent ? model_geometry.transparent_index_count : model_geometry.index_count;
2238 if( index_count == 0u )
2239 continue;
2240
2241 const unsigned int first_index= transparent ? model_geometry.first_transparent_index : model_geometry.first_index;
2242 const unsigned int first_animation_vertex=
2243 model_geometry.first_animations_vertex +
2244 model_geometry.animations_vertex_count * static_model.animation_frame;
2245
2246 m_Mat4 model_matrix;
2247 m_Mat3 lightmap_matrix, rotation_matrix;
2248 CreateModelMatrices( static_model.pos, static_model.angle, model_matrix, lightmap_matrix );
2249 rotation_matrix.RotateZ( -static_model.angle );
2250
2251 models_shadow_shader_.Uniform( "view_matrix", model_matrix * view_matrix );
2252 models_shadow_shader_.Uniform( "first_animation_vertex_number", int(first_animation_vertex) );
2253 models_shadow_shader_.Uniform( "light_pos", ( light_pos - static_model.pos ) * rotation_matrix );
2254
2255 glDrawElementsBaseVertex(
2256 GL_TRIANGLES,
2257 index_count,
2258 GL_UNSIGNED_SHORT,
2259 reinterpret_cast<void*>( first_index * sizeof(unsigned short) ),
2260 model_geometry.first_vertex_index );
2261 }

Callers

nothing calls this directly

Calls 3

GetNearestLightSourcePosFunction · 0.85
CreateModelMatricesFunction · 0.85
BindMethod · 0.80

Tested by

no test coverage detected