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

Method SetMap

PanzerChasm/client/map_drawer_soft.cpp:180–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178{}
179
180void MapDrawerSoft::SetMap( const MapDataConstPtr& map_data )
181{
182 if( map_data == current_map_data_ )
183 return;
184
185 current_map_data_= map_data;
186 if( map_data == nullptr )
187 return; // TODO - if map is null - clear resources, etc.
188
189 surfaces_cache_.Clear();
190
191 map_bsp_tree_.reset( new MapBSPTree( map_data ) );
192
193 LoadModelsGroup( map_data->models, map_models_ );
194 LoadWallsTextures( *map_data );
195 LoadFloorsTextures( *map_data );
196 LoadWalls( *map_data );
197 LoadFloorsAndCeilings( *map_data );
198
199 // Sky
200 if( std::strcmp( sky_texture_.file_name, current_map_data_->sky_texture_name ) != 0 )
201 {
202 std::strncpy( sky_texture_.file_name, current_map_data_->sky_texture_name, sizeof(sky_texture_.file_name) );
203
204 char sky_texture_file_path[ MapData::c_max_file_path_size ];
205 std::snprintf( sky_texture_file_path, sizeof(sky_texture_file_path), "COMMON/%s", current_map_data_->sky_texture_name );
206
207 const Vfs::FileContent sky_texture_data= game_resources_->vfs->ReadFile( sky_texture_file_path );
208 const CelTextureHeader& cel_header= *reinterpret_cast<const CelTextureHeader*>( sky_texture_data.data() );
209
210 const unsigned int sky_pixel_count= cel_header.size[0] * cel_header.size[1];
211 sky_texture_.data.resize( sky_pixel_count );
212
213 const PaletteTransformed& palette= *rendering_context_.palette_transformed;
214 const unsigned char* const src= sky_texture_data.data() + sizeof(CelTextureHeader);
215
216 for( unsigned int i= 0u; i < sky_pixel_count; i++ )
217 sky_texture_.data[i]= palette[src[i]];
218
219 sky_texture_.size[0]= cel_header.size[0];
220 sky_texture_.size[1]= cel_header.size[1];
221 }
222}
223
224void MapDrawerSoft::Draw(
225 const MapState& map_state,

Callers

nothing calls this directly

Calls 2

ReadFileMethod · 0.80
ClearMethod · 0.45

Tested by

no test coverage detected