Use a separate update() member
This commit is contained in:
parent
61d70ea599
commit
1e1ba34f45
@ -54,21 +54,13 @@ void STKAnimatedMesh::setMesh(scene::IAnimatedMesh* mesh)
|
|||||||
CAnimatedMeshSceneNode::setMesh(mesh);
|
CAnimatedMeshSceneNode::setMesh(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void STKAnimatedMesh::render()
|
void STKAnimatedMesh::update()
|
||||||
{
|
{
|
||||||
video::IVideoDriver* driver = SceneManager->getVideoDriver();
|
video::IVideoDriver* driver = SceneManager->getVideoDriver();
|
||||||
|
|
||||||
bool isTransparentPass =
|
|
||||||
SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT;
|
|
||||||
|
|
||||||
++PassCount;
|
|
||||||
|
|
||||||
scene::IMesh* m = getMeshForCurrentFrame();
|
scene::IMesh* m = getMeshForCurrentFrame();
|
||||||
|
|
||||||
if (m)
|
if (m)
|
||||||
{
|
|
||||||
Box = m->getBoundingBox();
|
Box = m->getBoundingBox();
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log::error("animated mesh", "Animated Mesh returned no mesh to render.");
|
Log::error("animated mesh", "Animated Mesh returned no mesh to render.");
|
||||||
@ -142,8 +134,6 @@ void STKAnimatedMesh::render()
|
|||||||
scene::IMeshBuffer* mb = m->getMeshBuffer(i);
|
scene::IMeshBuffer* mb = m->getMeshBuffer(i);
|
||||||
const video::SMaterial& material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i];
|
const video::SMaterial& material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i];
|
||||||
if (isObject(material.MaterialType))
|
if (isObject(material.MaterialType))
|
||||||
{
|
|
||||||
if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS || irr_driver->getPhase() == TRANSPARENT_PASS)
|
|
||||||
{
|
{
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
size_t size = mb->getVertexCount() * GLmeshes[i].Stride;
|
size_t size = mb->getVertexCount() * GLmeshes[i].Stride;
|
||||||
@ -157,19 +147,21 @@ void STKAnimatedMesh::render()
|
|||||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (mb)
|
if (mb)
|
||||||
GLmeshes[i].TextureMatrix = getMaterial(i).getTextureMatrix(0);
|
GLmeshes[i].TextureMatrix = getMaterial(i).getTextureMatrix(0);
|
||||||
|
|
||||||
video::IMaterialRenderer* rnd = driver->getMaterialRenderer(Materials[i].MaterialType);
|
|
||||||
bool transparent = (rnd && rnd->isTransparent());
|
|
||||||
|
|
||||||
// only render transparent buffer if this is the transparent render pass
|
|
||||||
// and solid only in solid pass
|
|
||||||
if (transparent != isTransparentPass)
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void STKAnimatedMesh::render()
|
||||||
|
{
|
||||||
|
bool isTransparentPass =
|
||||||
|
SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT;
|
||||||
|
|
||||||
|
++PassCount;
|
||||||
|
|
||||||
|
update();
|
||||||
|
|
||||||
if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS || irr_driver->getPhase() == SHADOW_PASS)
|
if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS || irr_driver->getPhase() == SHADOW_PASS)
|
||||||
{
|
{
|
||||||
ModelViewProjectionMatrix = computeMVP(AbsoluteTransformation);
|
ModelViewProjectionMatrix = computeMVP(AbsoluteTransformation);
|
||||||
|
@ -17,6 +17,7 @@ protected:
|
|||||||
core::matrix4 ModelViewProjectionMatrix;
|
core::matrix4 ModelViewProjectionMatrix;
|
||||||
void cleanGLMeshes();
|
void cleanGLMeshes();
|
||||||
public:
|
public:
|
||||||
|
void update();
|
||||||
STKAnimatedMesh(irr::scene::IAnimatedMesh* mesh, irr::scene::ISceneNode* parent,
|
STKAnimatedMesh(irr::scene::IAnimatedMesh* mesh, irr::scene::ISceneNode* parent,
|
||||||
irr::scene::ISceneManager* mgr, irr::s32 id,
|
irr::scene::ISceneManager* mgr, irr::s32 id,
|
||||||
const irr::core::vector3df& position = irr::core::vector3df(0,0,0),
|
const irr::core::vector3df& position = irr::core::vector3df(0,0,0),
|
||||||
|
@ -183,6 +183,21 @@ void STKMeshSceneNode::updatevbo()
|
|||||||
|
|
||||||
static video::ITexture *spareWhiteTex = 0;
|
static video::ITexture *spareWhiteTex = 0;
|
||||||
|
|
||||||
|
void STKMeshSceneNode::update()
|
||||||
|
{
|
||||||
|
Box = Mesh->getBoundingBox();
|
||||||
|
|
||||||
|
setFirstTimeMaterial();
|
||||||
|
|
||||||
|
for (u32 i = 0; i < Mesh->getMeshBufferCount(); ++i)
|
||||||
|
{
|
||||||
|
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
|
||||||
|
if (!mb)
|
||||||
|
continue;
|
||||||
|
GLmeshes[i].TextureMatrix = getMaterial(i).getTextureMatrix(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void STKMeshSceneNode::OnRegisterSceneNode()
|
void STKMeshSceneNode::OnRegisterSceneNode()
|
||||||
{
|
{
|
||||||
@ -201,24 +216,13 @@ void STKMeshSceneNode::render()
|
|||||||
|
|
||||||
++PassCount;
|
++PassCount;
|
||||||
|
|
||||||
Box = Mesh->getBoundingBox();
|
update();
|
||||||
|
|
||||||
setFirstTimeMaterial();
|
|
||||||
|
|
||||||
for (u32 i = 0; i < Mesh->getMeshBufferCount(); ++i)
|
|
||||||
{
|
|
||||||
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
|
|
||||||
if (!mb)
|
|
||||||
continue;
|
|
||||||
GLmeshes[i].TextureMatrix = getMaterial(i).getTextureMatrix(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS && immediate_draw)
|
if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS && immediate_draw)
|
||||||
{
|
{
|
||||||
core::matrix4 invmodel;
|
core::matrix4 invmodel;
|
||||||
AbsoluteTransformation.getInverse(invmodel);
|
AbsoluteTransformation.getInverse(invmodel);
|
||||||
|
|
||||||
|
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
if (update_each_frame)
|
if (update_each_frame)
|
||||||
updatevbo();
|
updatevbo();
|
||||||
|
@ -32,6 +32,7 @@ public:
|
|||||||
const irr::core::vector3df& scale = irr::core::vector3df(1.0f, 1.0f, 1.0f),
|
const irr::core::vector3df& scale = irr::core::vector3df(1.0f, 1.0f, 1.0f),
|
||||||
bool createGLMeshes = true);
|
bool createGLMeshes = true);
|
||||||
virtual void render();
|
virtual void render();
|
||||||
|
void update();
|
||||||
virtual void setMesh(irr::scene::IMesh* mesh);
|
virtual void setMesh(irr::scene::IMesh* mesh);
|
||||||
virtual void OnRegisterSceneNode();
|
virtual void OnRegisterSceneNode();
|
||||||
virtual ~STKMeshSceneNode();
|
virtual ~STKMeshSceneNode();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user