1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-04-15 09:06:46 +00:00

Fix some subentity assumptions

This commit is contained in:
Chris Robinson 2013-01-10 06:35:06 -08:00
parent 7f2d71554e
commit e8ac3976b5

View file

@ -205,19 +205,22 @@ unsigned int Moon::getPhaseInt() const
void SkyManager::ModVertexAlpha(Entity* ent, unsigned int meshType) void SkyManager::ModVertexAlpha(Entity* ent, unsigned int meshType)
{ {
for(unsigned int idx = 0;idx < ent->getNumSubEntities();idx++)
{
Ogre::SubMesh *submesh = ent->getSubEntity(idx)->getSubMesh();
// Get the vertex colour buffer of this mesh // Get the vertex colour buffer of this mesh
const Ogre::VertexElement* ves_diffuse = ent->getMesh()->getSubMesh(0)->vertexData->vertexDeclaration->findElementBySemantic( Ogre::VES_DIFFUSE ); const Ogre::VertexElement* ves_diffuse = submesh->vertexData->vertexDeclaration->findElementBySemantic( Ogre::VES_DIFFUSE );
HardwareVertexBufferSharedPtr colourBuffer = ent->getMesh()->getSubMesh(0)->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource()); HardwareVertexBufferSharedPtr colourBuffer = submesh->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource());
// Lock // Lock
void* pData = colourBuffer->lock(HardwareBuffer::HBL_NORMAL); void* pData = colourBuffer->lock(HardwareBuffer::HBL_NORMAL);
// Iterate over all vertices // Iterate over all vertices
int vertex_size = colourBuffer->getVertexSize(); int vertex_size = colourBuffer->getVertexSize();
float * currentVertex = NULL;
for (unsigned int i=0; i<colourBuffer->getNumVertices(); ++i) for (unsigned int i=0; i<colourBuffer->getNumVertices(); ++i)
{ {
// Get a pointer to the vertex colour // Get a pointer to the vertex colour
float *currentVertex = NULL;
ves_diffuse->baseVertexPointerToElement( pData, &currentVertex ); ves_diffuse->baseVertexPointerToElement( pData, &currentVertex );
unsigned char alpha=0; unsigned char alpha=0;
@ -242,7 +245,8 @@ void SkyManager::ModVertexAlpha(Entity* ent, unsigned int meshType)
} }
// Unlock // Unlock
ent->getMesh()->getSubMesh(0)->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource())->unlock(); colourBuffer->unlock();
}
} }
SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera)
@ -356,7 +360,8 @@ void SkyManager::create()
atmosphere_ent->setCastShadows(false); atmosphere_ent->setCastShadows(false);
atmosphere_ent->setRenderQueueGroup(RQG_SkiesEarly); atmosphere_ent->setRenderQueueGroup(RQG_SkiesEarly);
atmosphere_ent->setVisibilityFlags(RV_Sky); atmosphere_ent->setVisibilityFlags(RV_Sky);
atmosphere_ent->getSubEntity (0)->setMaterialName ("openmw_atmosphere"); for(unsigned int j = 0;j < atmosphere_ent->getNumSubEntities();j++)
atmosphere_ent->getSubEntity (j)->setMaterialName("openmw_atmosphere");
ModVertexAlpha(atmosphere_ent, 0); ModVertexAlpha(atmosphere_ent, 0);
} }
@ -369,7 +374,8 @@ void SkyManager::create()
Entity* clouds_ent = entities.mEntities[i]; Entity* clouds_ent = entities.mEntities[i];
clouds_ent->setVisibilityFlags(RV_Sky); clouds_ent->setVisibilityFlags(RV_Sky);
clouds_ent->setRenderQueueGroup(RQG_SkiesEarly+5); clouds_ent->setRenderQueueGroup(RQG_SkiesEarly+5);
clouds_ent->getSubEntity(0)->setMaterialName ("openmw_clouds"); for(unsigned int j = 0;j < clouds_ent->getNumSubEntities();j++)
clouds_ent->getSubEntity(j)->setMaterialName("openmw_clouds");
clouds_ent->setCastShadows(false); clouds_ent->setCastShadows(false);
ModVertexAlpha(clouds_ent, 1); ModVertexAlpha(clouds_ent, 1);