Use tangent space meshes only when shaders are enabled
This commit is contained in:
parent
0e75eb4324
commit
bf884e37a0
|
@ -1167,7 +1167,7 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
|
||||||
|
|
||||||
for(u32 j = 0; j < p.vertices.size(); j++)
|
for(u32 j = 0; j < p.vertices.size(); j++)
|
||||||
{
|
{
|
||||||
video::S3DVertexTangents *vertex = &p.vertices[j];
|
video::S3DVertex *vertex = &p.vertices[j];
|
||||||
// Note applyFacesShading second parameter is precalculated sqrt
|
// Note applyFacesShading second parameter is precalculated sqrt
|
||||||
// value for speed improvement
|
// value for speed improvement
|
||||||
// Skip it for lightsources and top faces.
|
// Skip it for lightsources and top faces.
|
||||||
|
@ -1221,11 +1221,12 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create meshbuffer
|
// Create meshbuffer
|
||||||
scene::SMeshBufferTangents *buf = new scene::SMeshBufferTangents();
|
scene::SMeshBuffer *buf = new scene::SMeshBuffer();
|
||||||
// Set material
|
// Set material
|
||||||
buf->Material = material;
|
buf->Material = material;
|
||||||
// Add to mesh
|
// Add to mesh
|
||||||
m_mesh->addMeshBuffer(buf);
|
scene::SMesh *mesh = (scene::SMesh *)m_mesh;
|
||||||
|
mesh->addMeshBuffer(buf);
|
||||||
// Mesh grabbed it
|
// Mesh grabbed it
|
||||||
buf->drop();
|
buf->drop();
|
||||||
buf->append(&p.vertices[0], p.vertices.size(),
|
buf->append(&p.vertices[0], p.vertices.size(),
|
||||||
|
@ -1241,7 +1242,9 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
|
||||||
|
|
||||||
if (m_enable_shaders) {
|
if (m_enable_shaders) {
|
||||||
scene::IMeshManipulator* meshmanip = m_gamedef->getSceneManager()->getMeshManipulator();
|
scene::IMeshManipulator* meshmanip = m_gamedef->getSceneManager()->getMeshManipulator();
|
||||||
meshmanip->recalculateTangents(m_mesh, true, false, false);
|
scene::IMesh* tangentMesh = meshmanip->createMeshWithTangents(m_mesh);
|
||||||
|
m_mesh->drop();
|
||||||
|
m_mesh = tangentMesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_mesh)
|
if(m_mesh)
|
||||||
|
@ -1361,7 +1364,7 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_rat
|
||||||
i != m_daynight_diffs.end(); ++i)
|
i != m_daynight_diffs.end(); ++i)
|
||||||
{
|
{
|
||||||
scene::IMeshBuffer *buf = m_mesh->getMeshBuffer(i->first);
|
scene::IMeshBuffer *buf = m_mesh->getMeshBuffer(i->first);
|
||||||
video::S3DVertexTangents *vertices = (video::S3DVertexTangents *)buf->getVertices();
|
video::S3DVertex *vertices = (video::S3DVertex *)buf->getVertices();
|
||||||
for(std::map<u32, std::pair<u8, u8 > >::iterator
|
for(std::map<u32, std::pair<u8, u8 > >::iterator
|
||||||
j = i->second.begin();
|
j = i->second.begin();
|
||||||
j != i->second.end(); ++j)
|
j != i->second.end(); ++j)
|
||||||
|
@ -1392,7 +1395,7 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_rat
|
||||||
i != m_highlighted_materials.end(); ++i)
|
i != m_highlighted_materials.end(); ++i)
|
||||||
{
|
{
|
||||||
scene::IMeshBuffer *buf = m_mesh->getMeshBuffer(*i);
|
scene::IMeshBuffer *buf = m_mesh->getMeshBuffer(*i);
|
||||||
video::S3DVertexTangents *vertices = (video::S3DVertexTangents*)buf->getVertices();
|
video::S3DVertex *vertices = (video::S3DVertex *)buf->getVertices();
|
||||||
for (u32 j = 0; j < buf->getVertexCount() ;j++)
|
for (u32 j = 0; j < buf->getVertexCount() ;j++)
|
||||||
vertices[j].Color = hc;
|
vertices[j].Color = hc;
|
||||||
}
|
}
|
||||||
|
@ -1448,7 +1451,7 @@ void MeshCollector::append(const TileSpec &tile,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (u32 i = 0; i < numVertices; i++) {
|
for (u32 i = 0; i < numVertices; i++) {
|
||||||
video::S3DVertexTangents vert(vertices[i].Pos, vertices[i].Normal,
|
video::S3DVertex vert(vertices[i].Pos, vertices[i].Normal,
|
||||||
vertices[i].Color, vertices[i].TCoords);
|
vertices[i].Color, vertices[i].TCoords);
|
||||||
p->vertices.push_back(vert);
|
p->vertices.push_back(vert);
|
||||||
}
|
}
|
||||||
|
@ -1494,7 +1497,7 @@ void MeshCollector::append(const TileSpec &tile,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (u32 i = 0; i < numVertices; i++) {
|
for (u32 i = 0; i < numVertices; i++) {
|
||||||
video::S3DVertexTangents vert(vertices[i].Pos + pos, vertices[i].Normal,
|
video::S3DVertex vert(vertices[i].Pos + pos, vertices[i].Normal,
|
||||||
c, vertices[i].TCoords);
|
c, vertices[i].TCoords);
|
||||||
p->vertices.push_back(vert);
|
p->vertices.push_back(vert);
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ public:
|
||||||
// Returns true if anything has been changed.
|
// Returns true if anything has been changed.
|
||||||
bool animate(bool faraway, float time, int crack, u32 daynight_ratio);
|
bool animate(bool faraway, float time, int crack, u32 daynight_ratio);
|
||||||
|
|
||||||
scene::SMesh *getMesh()
|
scene::IMesh *getMesh()
|
||||||
{
|
{
|
||||||
return m_mesh;
|
return m_mesh;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ public:
|
||||||
void updateCameraOffset(v3s16 camera_offset);
|
void updateCameraOffset(v3s16 camera_offset);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
scene::SMesh *m_mesh;
|
scene::IMesh *m_mesh;
|
||||||
MinimapMapblock *m_minimap_mapblock;
|
MinimapMapblock *m_minimap_mapblock;
|
||||||
IGameDef *m_gamedef;
|
IGameDef *m_gamedef;
|
||||||
ITextureSource *m_tsrc;
|
ITextureSource *m_tsrc;
|
||||||
|
@ -177,7 +177,7 @@ struct PreMeshBuffer
|
||||||
{
|
{
|
||||||
TileSpec tile;
|
TileSpec tile;
|
||||||
std::vector<u16> indices;
|
std::vector<u16> indices;
|
||||||
std::vector<video::S3DVertexTangents> vertices;
|
std::vector<video::S3DVertex> vertices;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MeshCollector
|
struct MeshCollector
|
||||||
|
|
Loading…
Reference in New Issue