Recalculate normals for cached meshes.
Check if mesh is here before adding to meshcollector. Fix deleting the meshes.
This commit is contained in:
parent
9029a34cc6
commit
d221917170
|
@ -2781,6 +2781,10 @@ IShaderSource* Client::getShaderSource()
|
||||||
{
|
{
|
||||||
return m_shsrc;
|
return m_shsrc;
|
||||||
}
|
}
|
||||||
|
scene::ISceneManager* Client::getSceneManager()
|
||||||
|
{
|
||||||
|
return m_device->getSceneManager();
|
||||||
|
}
|
||||||
u16 Client::allocateUnknownNodeId(const std::string &name)
|
u16 Client::allocateUnknownNodeId(const std::string &name)
|
||||||
{
|
{
|
||||||
errorstream<<"Client::allocateUnknownNodeId(): "
|
errorstream<<"Client::allocateUnknownNodeId(): "
|
||||||
|
|
|
@ -447,6 +447,7 @@ public:
|
||||||
virtual ICraftDefManager* getCraftDefManager();
|
virtual ICraftDefManager* getCraftDefManager();
|
||||||
virtual ITextureSource* getTextureSource();
|
virtual ITextureSource* getTextureSource();
|
||||||
virtual IShaderSource* getShaderSource();
|
virtual IShaderSource* getShaderSource();
|
||||||
|
virtual scene::ISceneManager* getSceneManager();
|
||||||
virtual u16 allocateUnknownNodeId(const std::string &name);
|
virtual u16 allocateUnknownNodeId(const std::string &name);
|
||||||
virtual ISoundManager* getSoundManager();
|
virtual ISoundManager* getSoundManager();
|
||||||
virtual MtEventManager* getEventManager();
|
virtual MtEventManager* getEventManager();
|
||||||
|
|
|
@ -1720,11 +1720,13 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
||||||
v3f pos = intToFloat(p, BS);
|
v3f pos = intToFloat(p, BS);
|
||||||
video::SColor c = MapBlock_LightColor(255, getInteriorLight(n, 1, nodedef), f.light_source);
|
video::SColor c = MapBlock_LightColor(255, getInteriorLight(n, 1, nodedef), f.light_source);
|
||||||
u8 facedir = n.getFaceDir(nodedef);
|
u8 facedir = n.getFaceDir(nodedef);
|
||||||
for(u16 j = 0; j < f.mesh_ptr[facedir]->getMeshBufferCount(); j++) {
|
if (f.mesh_ptr[facedir]) {
|
||||||
scene::IMeshBuffer *buf = f.mesh_ptr[facedir]->getMeshBuffer(j);
|
for(u16 j = 0; j < f.mesh_ptr[facedir]->getMeshBufferCount(); j++) {
|
||||||
collector.append(getNodeTileN(n, p, j, data),
|
scene::IMeshBuffer *buf = f.mesh_ptr[facedir]->getMeshBuffer(j);
|
||||||
(video::S3DVertex *)buf->getVertices(), buf->getVertexCount(),
|
collector.append(getNodeTileN(n, p, j, data),
|
||||||
buf->getIndices(), buf->getIndexCount(), pos, c);
|
(video::S3DVertex *)buf->getVertices(), buf->getVertexCount(),
|
||||||
|
buf->getIndices(), buf->getIndexCount(), pos, c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;}
|
break;}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ class MtEventManager;
|
||||||
class IRollbackReportSink;
|
class IRollbackReportSink;
|
||||||
namespace irr { namespace scene {
|
namespace irr { namespace scene {
|
||||||
class IAnimatedMesh;
|
class IAnimatedMesh;
|
||||||
|
class ISceneManager;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -63,6 +64,7 @@ public:
|
||||||
virtual MtEventManager* getEventManager()=0;
|
virtual MtEventManager* getEventManager()=0;
|
||||||
virtual scene::IAnimatedMesh* getMesh(const std::string &filename)
|
virtual scene::IAnimatedMesh* getMesh(const std::string &filename)
|
||||||
{ return NULL; }
|
{ return NULL; }
|
||||||
|
virtual scene::ISceneManager* getSceneManager()=0;
|
||||||
|
|
||||||
// Only usable on the server, and NOT thread-safe. It is usable from the
|
// Only usable on the server, and NOT thread-safe. It is usable from the
|
||||||
// environment thread.
|
// environment thread.
|
||||||
|
|
|
@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#ifndef SERVER
|
#ifndef SERVER
|
||||||
#include "tile.h"
|
#include "tile.h"
|
||||||
#include "mesh.h"
|
#include "mesh.h"
|
||||||
|
#include <IMeshManipulator.h>
|
||||||
#endif
|
#endif
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
@ -171,12 +172,6 @@ ContentFeatures::ContentFeatures()
|
||||||
|
|
||||||
ContentFeatures::~ContentFeatures()
|
ContentFeatures::~ContentFeatures()
|
||||||
{
|
{
|
||||||
#ifndef SERVER
|
|
||||||
for (u32 i = 0; i < 24; i++) {
|
|
||||||
if (mesh_ptr[i])
|
|
||||||
mesh_ptr[i]->drop();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentFeatures::reset()
|
void ContentFeatures::reset()
|
||||||
|
@ -446,6 +441,15 @@ CNodeDefManager::CNodeDefManager()
|
||||||
|
|
||||||
CNodeDefManager::~CNodeDefManager()
|
CNodeDefManager::~CNodeDefManager()
|
||||||
{
|
{
|
||||||
|
#ifndef SERVER
|
||||||
|
for (u32 i = 0; i < m_content_features.size(); i++) {
|
||||||
|
ContentFeatures *f = &m_content_features[i];
|
||||||
|
for (u32 j = 0; j < 24; j++) {
|
||||||
|
if (f->mesh_ptr[j])
|
||||||
|
f->mesh_ptr[j]->drop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -695,6 +699,8 @@ void CNodeDefManager::updateTextures(IGameDef *gamedef)
|
||||||
|
|
||||||
ITextureSource *tsrc = gamedef->tsrc();
|
ITextureSource *tsrc = gamedef->tsrc();
|
||||||
IShaderSource *shdsrc = gamedef->getShaderSource();
|
IShaderSource *shdsrc = gamedef->getShaderSource();
|
||||||
|
scene::ISceneManager* smgr = gamedef->getSceneManager();
|
||||||
|
scene::IMeshManipulator* meshmanip = smgr->getMeshManipulator();
|
||||||
|
|
||||||
bool new_style_water = g_settings->getBool("new_style_water");
|
bool new_style_water = g_settings->getBool("new_style_water");
|
||||||
bool new_style_leaves = g_settings->getBool("new_style_leaves");
|
bool new_style_leaves = g_settings->getBool("new_style_leaves");
|
||||||
|
@ -840,18 +846,23 @@ void CNodeDefManager::updateTextures(IGameDef *gamedef)
|
||||||
// Read the mesh and apply scale
|
// Read the mesh and apply scale
|
||||||
if ((f->drawtype == NDT_MESH) && (f->mesh != "")) {
|
if ((f->drawtype == NDT_MESH) && (f->mesh != "")) {
|
||||||
f->mesh_ptr[0] = gamedef->getMesh(f->mesh);
|
f->mesh_ptr[0] = gamedef->getMesh(f->mesh);
|
||||||
scaleMesh(f->mesh_ptr[0], v3f(f->visual_scale,f->visual_scale,f->visual_scale));
|
if (f->mesh_ptr[0]){
|
||||||
recalculateBoundingBox(f->mesh_ptr[0]);
|
v3f scale = v3f(1.0, 1.0, 1.0) * BS * f->visual_scale;
|
||||||
|
scaleMesh(f->mesh_ptr[0], scale);
|
||||||
|
recalculateBoundingBox(f->mesh_ptr[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Convert regular nodebox nodes to meshnodes
|
//Convert regular nodebox nodes to meshnodes
|
||||||
//Change the drawtype and apply scale
|
//Change the drawtype and apply scale
|
||||||
if ((f->drawtype == NDT_NODEBOX) &&
|
else if ((f->drawtype == NDT_NODEBOX) &&
|
||||||
((f->node_box.type == NODEBOX_REGULAR) || (f->node_box.type == NODEBOX_FIXED)) &&
|
((f->node_box.type == NODEBOX_REGULAR) ||
|
||||||
|
(f->node_box.type == NODEBOX_FIXED)) &&
|
||||||
(!f->node_box.fixed.empty())) {
|
(!f->node_box.fixed.empty())) {
|
||||||
f->drawtype = NDT_MESH;
|
f->drawtype = NDT_MESH;
|
||||||
f->mesh_ptr[0] = convertNodeboxNodeToMesh(f);
|
f->mesh_ptr[0] = convertNodeboxNodeToMesh(f);
|
||||||
scaleMesh(f->mesh_ptr[0], v3f(f->visual_scale,f->visual_scale,f->visual_scale));
|
v3f scale = v3f(1.0, 1.0, 1.0) * f->visual_scale;
|
||||||
|
scaleMesh(f->mesh_ptr[0], scale);
|
||||||
recalculateBoundingBox(f->mesh_ptr[0]);
|
recalculateBoundingBox(f->mesh_ptr[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -861,6 +872,7 @@ void CNodeDefManager::updateTextures(IGameDef *gamedef)
|
||||||
f->mesh_ptr[j] = cloneMesh(f->mesh_ptr[0]);
|
f->mesh_ptr[j] = cloneMesh(f->mesh_ptr[0]);
|
||||||
rotateMeshBy6dFacedir(f->mesh_ptr[j], j);
|
rotateMeshBy6dFacedir(f->mesh_ptr[j], j);
|
||||||
recalculateBoundingBox(f->mesh_ptr[j]);
|
recalculateBoundingBox(f->mesh_ptr[j]);
|
||||||
|
meshmanip->recalculateNormals(f->mesh_ptr[j], false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4890,6 +4890,11 @@ IShaderSource* Server::getShaderSource()
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
scene::ISceneManager* Server::getSceneManager()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
u16 Server::allocateUnknownNodeId(const std::string &name)
|
u16 Server::allocateUnknownNodeId(const std::string &name)
|
||||||
{
|
{
|
||||||
return m_nodedef->allocateDummy(name);
|
return m_nodedef->allocateDummy(name);
|
||||||
|
|
|
@ -290,7 +290,8 @@ public:
|
||||||
virtual ISoundManager* getSoundManager();
|
virtual ISoundManager* getSoundManager();
|
||||||
virtual MtEventManager* getEventManager();
|
virtual MtEventManager* getEventManager();
|
||||||
virtual IRollbackReportSink* getRollbackReportSink();
|
virtual IRollbackReportSink* getRollbackReportSink();
|
||||||
|
virtual scene::ISceneManager* getSceneManager();
|
||||||
|
|
||||||
IWritableItemDefManager* getWritableItemDefManager();
|
IWritableItemDefManager* getWritableItemDefManager();
|
||||||
IWritableNodeDefManager* getWritableNodeDefManager();
|
IWritableNodeDefManager* getWritableNodeDefManager();
|
||||||
IWritableCraftDefManager* getWritableCraftDefManager();
|
IWritableCraftDefManager* getWritableCraftDefManager();
|
||||||
|
|
Loading…
Reference in New Issue