forked from oerkki/voxelands
Fix some things
This commit is contained in:
parent
a1ec501f26
commit
b20fffb931
|
@ -34,7 +34,10 @@
|
|||
#include "sound.h"
|
||||
|
||||
#ifndef SERVER
|
||||
|
||||
float roundf(float x)
|
||||
{
|
||||
return (float)((x < 0) ? (ceil((x) - 0.5)) : (floor((x) + 0.5)));
|
||||
}
|
||||
static const v3s16 corners[8] = {
|
||||
v3s16(-1, 1, 1),
|
||||
v3s16( 1, 1, 1),
|
||||
|
@ -2709,10 +2712,10 @@ void meshgen_liquid(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &selec
|
|||
|
||||
if (top_is_same_liquid == false) {
|
||||
video::S3DVertex vertices[4] = {
|
||||
video::S3DVertex(-0.5*data->m_BS,0, 0.5*data->m_BS, 0,0,0, video::SColor(255,255,255,255), tiles[0].texture.x1(), tiles[0].texture.y1()),
|
||||
video::S3DVertex( 0.5*data->m_BS,0, 0.5*data->m_BS, 0,0,0, video::SColor(255,255,255,255), tiles[0].texture.x0(), tiles[0].texture.y1()),
|
||||
video::S3DVertex( 0.5*data->m_BS,0,-0.5*data->m_BS, 0,0,0, video::SColor(255,255,255,255), tiles[0].texture.x0(), tiles[0].texture.y0()),
|
||||
video::S3DVertex(-0.5*data->m_BS,0,-0.5*data->m_BS, 0,0,0, video::SColor(255,255,255,255), tiles[0].texture.x1(), tiles[0].texture.y0())
|
||||
video::S3DVertex(-0.5*data->m_BS,0, 0.5*data->m_BS, 0,0,0, video::SColor(255,255,255,255), tiles[0].texture.x0(), tiles[0].texture.y1()),
|
||||
video::S3DVertex( 0.5*data->m_BS,0, 0.5*data->m_BS, 0,0,0, video::SColor(255,255,255,255), tiles[0].texture.x1(), tiles[0].texture.y1()),
|
||||
video::S3DVertex( 0.5*data->m_BS,0,-0.5*data->m_BS, 0,0,0, video::SColor(255,255,255,255), tiles[0].texture.x1(), tiles[0].texture.y0()),
|
||||
video::S3DVertex(-0.5*data->m_BS,0,-0.5*data->m_BS, 0,0,0, video::SColor(255,255,255,255), tiles[0].texture.x0(), tiles[0].texture.y0())
|
||||
};
|
||||
|
||||
// To get backface culling right, the vertices need to go
|
||||
|
@ -2730,15 +2733,15 @@ void meshgen_liquid(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &selec
|
|||
// -Z towards +Z, thus the direction is +Z.
|
||||
// Rotate texture to make animation go in flow direction
|
||||
// Positive if liquid moves towards +Z
|
||||
int dz = (corner_levels[side_corners[2][0]] +
|
||||
corner_levels[side_corners[2][1]] <
|
||||
corner_levels[side_corners[3][0]] +
|
||||
corner_levels[side_corners[3][1]]);
|
||||
int dz = (corner_levels[side_corners[3][0]] +
|
||||
corner_levels[side_corners[3][1]]) -
|
||||
(corner_levels[side_corners[2][0]] +
|
||||
corner_levels[side_corners[2][1]]);
|
||||
// Positive if liquid moves towards +X
|
||||
int dx = (corner_levels[side_corners[0][0]] +
|
||||
corner_levels[side_corners[0][1]] <
|
||||
corner_levels[side_corners[1][0]] +
|
||||
corner_levels[side_corners[1][1]]);
|
||||
int dx = (corner_levels[side_corners[1][0]] +
|
||||
corner_levels[side_corners[1][1]]) -
|
||||
(corner_levels[side_corners[0][0]] +
|
||||
corner_levels[side_corners[0][1]]);
|
||||
// -X
|
||||
if (-dx >= abs(dz)) {
|
||||
v2f t = vertices[0].TCoords;
|
||||
|
|
|
@ -480,6 +480,7 @@ void MapBlockMesh::animate(float time)
|
|||
|
||||
AnimationData temp_data = it->second;
|
||||
const TileSpec &tile = temp_data.tile;
|
||||
|
||||
// Figure out current frame
|
||||
int frame = (int)(time * 1000 / tile.animation_frame_length_ms) % tile.animation_frame_count;
|
||||
|
||||
|
@ -500,7 +501,7 @@ void MapBlockMesh::animate(float time)
|
|||
scene::IMeshBuffer *buf = m_mesh->getMeshBuffer(it->first);
|
||||
|
||||
// Create new texture name from original
|
||||
if (g_texturesource && buf != 0) {
|
||||
if (g_texturesource && frame >= 0) {
|
||||
std::ostringstream os(std::ios::binary);
|
||||
os << g_texturesource->getTextureName(tile.texture.id);
|
||||
os << "^[verticalframe:" << (int)tile.animation_frame_count << ":" << frame;
|
||||
|
@ -725,12 +726,14 @@ void MapBlockMesh::generate(MeshMakeData *data, v3s16 camera_offset, JMutex *mut
|
|||
m_meshdata.swap(data->m_meshdata);
|
||||
m_fardata.swap(data->m_fardata);
|
||||
refresh(data->m_daynight_ratio);
|
||||
animate(0.0); // get first frame of animation
|
||||
m_mesh->recalculateBoundingBox();
|
||||
|
||||
if (mutex != NULL)
|
||||
mutex->Unlock();
|
||||
|
||||
// Get frist frame of animation AFTER the mutex is unlocked
|
||||
animate(0.0);
|
||||
|
||||
END_DEBUG_EXCEPTION_HANDLER(errorstream)
|
||||
}
|
||||
|
||||
|
|
|
@ -262,7 +262,7 @@ void SelectionMesh::generate(MeshMakeData *data)
|
|||
// it's a typedeffed CMeshBuffer<video::S3DVertex>
|
||||
scene::SMeshBuffer *buf = new scene::SMeshBuffer();
|
||||
// Set material
|
||||
buf->Material = d.material;
|
||||
buf->Material = d.tile.getMaterial();
|
||||
// Add to mesh
|
||||
mesh->addMeshBuffer(buf);
|
||||
// Mesh grabbed it
|
||||
|
|
|
@ -292,8 +292,11 @@ struct TileSpec
|
|||
animation_frame_count(0),
|
||||
animation_frame_length_ms(0)
|
||||
{
|
||||
#ifndef SERVER
|
||||
// init material only on clients
|
||||
video::SMaterial m;
|
||||
m_material = m;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool operator==(TileSpec &other)
|
||||
|
|
Loading…
Reference in New Issue