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

Method UpdateDynamicWalls

PanzerChasm/client/map_drawer_gl.cpp:1466–1520  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1464}
1465
1466void MapDrawerGL::UpdateDynamicWalls( const MapState::DynamicWalls& dynamic_walls )
1467{
1468 PC_ASSERT( current_map_data_->dynamic_walls.size() == dynamic_walls.size() );
1469
1470 for( unsigned int w= 0u; w < dynamic_walls.size(); w++ )
1471 {
1472 const MapData::Wall& map_wall= current_map_data_->dynamic_walls[w];
1473 const MapState::DynamicWall wall= dynamic_walls[w];
1474 // TODO - discard walls without textures.
1475
1476 WallVertex* const v= dynamc_walls_vertices_.data() + w * 4u;
1477
1478 v[0].xyz[0]= v[2].xyz[0]= short( wall.vert_pos[0].x * 256.0f );
1479 v[0].xyz[1]= v[2].xyz[1]= short( wall.vert_pos[0].y * 256.0f );
1480 v[1].xyz[0]= v[3].xyz[0]= short( wall.vert_pos[1].x * 256.0f );
1481 v[1].xyz[1]= v[3].xyz[1]= short( wall.vert_pos[1].y * 256.0f );
1482
1483 v[0].xyz[2]= v[1].xyz[2]= short( wall.z * 256.0f );
1484 v[2].xyz[2]= v[3].xyz[2]=v[0].xyz[2] + (2u << 8u);
1485
1486 v[0].texture_id= v[1].texture_id= v[2].texture_id= v[3].texture_id= wall.texture_id;
1487
1488 v[2].tex_coord[0]= v[0].tex_coord[0]= static_cast<short>( map_wall.vert_tex_coord[0] * 256.0f );
1489 v[1].tex_coord[0]= v[3].tex_coord[0]= static_cast<short>( map_wall.vert_tex_coord[1] * 256.0f );
1490
1491 v[0].tex_coord[1]= v[1].tex_coord[1]= 0;
1492 v[2].tex_coord[1]= v[3].tex_coord[1]= 256;
1493
1494 map_light_.GetDynamicWallLightmapCoord( w, v[0].lightmap_coord );
1495
1496 v[2].lightmap_coord[0]= v[0].lightmap_coord[0];
1497 v[2].lightmap_coord[1]= v[0].lightmap_coord[1];
1498 v[3].lightmap_coord[0]= v[1].lightmap_coord[0]= v[0].lightmap_coord[0] + 1u;
1499 v[3].lightmap_coord[1]= v[1].lightmap_coord[1]= v[0].lightmap_coord[1];
1500
1501 m_Vec2 wall_vec=
1502 m_Vec2(float(v[0].xyz[0]), float(v[0].xyz[1])) -
1503 m_Vec2(float(v[1].xyz[0]), float(v[1].xyz[1]));
1504 wall_vec.Normalize();
1505
1506 const int normal[2]= {
1507 int( +126.5f * wall_vec.y ),
1508 int( -126.5f * wall_vec.x ) };
1509 for( unsigned int j= 0u; j < 4u; j++ )
1510 {
1511 v[j].normal[0]= normal[0];
1512 v[j].normal[1]= normal[1];
1513 }
1514 }
1515
1516 dynamic_walls_geometry_.VertexSubData(
1517 dynamc_walls_vertices_.data(),
1518 dynamc_walls_vertices_.size() * sizeof(WallVertex),
1519 0u );
1520}
1521
1522void MapDrawerGL::PrepareModelsPolygonBuffer(
1523 std::vector<Model::Vertex>& vertices,

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected