aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSmallJoker <mk939@ymail.com>2016-07-26 14:39:03 +0200
committerparamat <mat.gregory@virginmedia.com>2016-07-27 22:21:41 +0100
commit8a98cbda8417c713e03d1ac0be80e88cd2f08a0c (patch)
treeb56815c8bc4f433dbcf4e6ab5339a4e3d14e1fb0 /src
parent2cb0f649f4429ffda9dbc2f8ef81d9a29914ec20 (diff)
downloadminetest-8a98cbda8417c713e03d1ac0be80e88cd2f08a0c.tar.gz
minetest-8a98cbda8417c713e03d1ac0be80e88cd2f08a0c.tar.bz2
minetest-8a98cbda8417c713e03d1ac0be80e88cd2f08a0c.zip
Upright sprite objects: Horizontally flip the front image
For consistent horizontal sprite structure when seen from front and back Fix code style
Diffstat (limited to 'src')
-rw-r--r--src/content_cao.cpp84
1 files changed, 40 insertions, 44 deletions
diff --git a/src/content_cao.cpp b/src/content_cao.cpp
index eeb85c8a6..f414b2b9b 100644
--- a/src/content_cao.cpp
+++ b/src/content_cao.cpp
@@ -839,54 +839,50 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr,
setBillboardTextureMatrix(m_spritenode,
txs, tys, 0, 0);
}
- }
- else if(m_prop.visual == "upright_sprite") {
+ } else if (m_prop.visual == "upright_sprite") {
scene::SMesh *mesh = new scene::SMesh();
- double dx = BS*m_prop.visual_size.X/2;
- double dy = BS*m_prop.visual_size.Y/2;
- { // Front
- scene::IMeshBuffer *buf = new scene::SMeshBuffer();
+ double dx = BS * m_prop.visual_size.X / 2;
+ double dy = BS * m_prop.visual_size.Y / 2;
u8 li = m_last_light;
- video::SColor c(255,li,li,li);
- video::S3DVertex vertices[4] =
- {
- video::S3DVertex(-dx,-dy,0, 0,0,0, c, 0,1),
- video::S3DVertex(dx,-dy,0, 0,0,0, c, 1,1),
- video::S3DVertex(dx,dy,0, 0,0,0, c, 1,0),
- video::S3DVertex(-dx,dy,0, 0,0,0, c, 0,0),
- };
- u16 indices[] = {0,1,2,2,3,0};
- buf->append(vertices, 4, indices, 6);
- // Set material
- buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
- buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
- buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
- buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
- // Add to mesh
- mesh->addMeshBuffer(buf);
- buf->drop();
+ video::SColor c(255, li, li, li);
+
+ { // Front
+ scene::IMeshBuffer *buf = new scene::SMeshBuffer();
+ video::S3DVertex vertices[4] = {
+ video::S3DVertex(-dx, -dy, 0, 0,0,0, c, 1,1),
+ video::S3DVertex( dx, -dy, 0, 0,0,0, c, 0,1),
+ video::S3DVertex( dx, dy, 0, 0,0,0, c, 0,0),
+ video::S3DVertex(-dx, dy, 0, 0,0,0, c, 1,0),
+ };
+ u16 indices[] = {0,1,2,2,3,0};
+ buf->append(vertices, 4, indices, 6);
+ // Set material
+ buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
+ buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
+ buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
+ buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
+ // Add to mesh
+ mesh->addMeshBuffer(buf);
+ buf->drop();
}
{ // Back
- scene::IMeshBuffer *buf = new scene::SMeshBuffer();
- u8 li = m_last_light;
- video::SColor c(255,li,li,li);
- video::S3DVertex vertices[4] =
- {
- video::S3DVertex(dx,-dy,0, 0,0,0, c, 1,1),
- video::S3DVertex(-dx,-dy,0, 0,0,0, c, 0,1),
- video::S3DVertex(-dx,dy,0, 0,0,0, c, 0,0),
- video::S3DVertex(dx,dy,0, 0,0,0, c, 1,0),
- };
- u16 indices[] = {0,1,2,2,3,0};
- buf->append(vertices, 4, indices, 6);
- // Set material
- buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
- buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
- buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
- buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
- // Add to mesh
- mesh->addMeshBuffer(buf);
- buf->drop();
+ scene::IMeshBuffer *buf = new scene::SMeshBuffer();
+ video::S3DVertex vertices[4] = {
+ video::S3DVertex( dx,-dy, 0, 0,0,0, c, 1,1),
+ video::S3DVertex(-dx,-dy, 0, 0,0,0, c, 0,1),
+ video::S3DVertex(-dx, dy, 0, 0,0,0, c, 0,0),
+ video::S3DVertex( dx, dy, 0, 0,0,0, c, 1,0),
+ };
+ u16 indices[] = {0,1,2,2,3,0};
+ buf->append(vertices, 4, indices, 6);
+ // Set material
+ buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
+ buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
+ buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
+ buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+ // Add to mesh
+ mesh->addMeshBuffer(buf);
+ buf->drop();
}
m_meshnode = smgr->addMeshSceneNode(mesh, NULL);
m_meshnode->grab();