Create StaticGeometry directly from Mesh

Minor issues with the Ogre API that can be trivial to fix
Post Reply
User avatar
ImpalerWrG
Gnoblar
Posts: 15
Joined: Sat Feb 27, 2010 7:42 am

Create StaticGeometry directly from Mesh

Post by ImpalerWrG » Sun Feb 24, 2013 11:19 am

StaticGeometry can currently only be built by attaching Entities with the following function

addEntity (Entity *ent, const Vector3 &position, const Quaternion &orientation=Quaternion::IDENTITY, const Vector3 &scale=Vector3::UNIT_SCALE)

The Entity is itself just an instance of a Mesh and every tutorial for use of staticGeometry I've seen warns you that you need to destroy the entity after assigning it to the Geometry or you will end up rendering both at a huge waste. Now if I'm correct the only thing addEntity dose is immediately rip the Mesh pointer and Material pointers out of Entity and works with them directly. So why are you forced to make Entities which are serving as nothing but temporary containers for this function and are then a liability. Lets have at least the option of doing this cleanly with the following function.

addMesh (Mesh* mesh, Material* mat, const Vector3 &position, const Quaternion &orientation=Quaternion::IDENTITY, const Vector3 &scale=Vector3::UNIT_SCALE)
0 x
Companions the creator seeks, not corpses, not herds and believers. Fellow creators, the creator seeks - those who write new values on new tablets. Companions the creator seeks, and fellow harvesters; for everything about him is ripe for the harvest.

bstone
OGRE Expert User
OGRE Expert User
Posts: 1920
Joined: Sun Feb 19, 2012 9:24 pm
Location: Russia

Re: Create StaticGeometry directly from Mesh

Post by bstone » Sun Feb 24, 2013 3:25 pm

As long as the entity is not attached to a scene node there's no way for it to get rendered twice after StaticGeometry::addEntity(). Also, passing direct pointers to reference-counted objects is something you should never do, FYI.
0 x

User avatar
ImpalerWrG
Gnoblar
Posts: 15
Joined: Sat Feb 27, 2010 7:42 am

Re: Create StaticGeometry directly from Mesh

Post by ImpalerWrG » Mon Feb 25, 2013 3:19 am

Use MeshPtr then if its an issue, but is this even a valid point when talking about staticGeometry, I though static geometry re-compiles all its data into a NEW mesh so unlike Entity it is not actually adding reference counts to the Mesh and the reference counter purpose of MeshPtr is moot.

My main point is still that the Entity is superfluous and people frequently stumble over this issue of not destroying the Entity, even if its not being rendered it's a waste of space storing it and a waste of time to create and destroy it.
0 x
Companions the creator seeks, not corpses, not herds and believers. Fellow creators, the creator seeks - those who write new values on new tablets. Companions the creator seeks, and fellow harvesters; for everything about him is ripe for the harvest.

User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2702
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 2

Re: Create StaticGeometry directly from Mesh

Post by syedhs » Mon Feb 25, 2013 5:47 am

Yes I think this is valid concern, probably the code can be changed in manner of few minutes:-

1) remove 'const MeshPtr& msh = ent->getMesh();' replaced with function parameter
2) line 'SubEntity* se = ent->getSubEntity(i);' is not needed.
3) line 'q->submesh = se->getSubMesh();' replaced with 'q->submesh = msh->getSubMesh(i);'
4) line 'q->materialName = se->getMaterialName();' replaced with 'q->materialName = msh->getSubMesh(i)->getMaterialName();'

I didn't test the code changes, but it seems ok (no compile error).
0 x
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me

bstone
OGRE Expert User
OGRE Expert User
Posts: 1920
Joined: Sun Feb 19, 2012 9:24 pm
Location: Russia

Re: Create StaticGeometry directly from Mesh

Post by bstone » Mon Feb 25, 2013 7:01 am

addEntity() is not superflous. The addMesh() code won't be equivalent because the main point of using entities there is that you can override materials both on an entity as a whole and on it's sub-entities if required. So at least replacing addEntity() with addMesh() would be a regression. Having addMesh() as a separate method won't hurt though.
0 x

User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2702
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 2

Re: Create StaticGeometry directly from Mesh

Post by syedhs » Mon Feb 25, 2013 12:00 pm

Yes you are right, although in most cases, the entity's material name is the same as mesh material.
0 x
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me

User avatar
ImpalerWrG
Gnoblar
Posts: 15
Joined: Sat Feb 27, 2010 7:42 am

Re: Create StaticGeometry directly from Mesh

Post by ImpalerWrG » Mon Dec 02, 2013 5:58 am

Any Progress on this? Do people actually do what your describing, build static geometry out of entities with altered materials on sub-entities? It sounds like a real edge case at best.
0 x
Companions the creator seeks, not corpses, not herds and believers. Fellow creators, the creator seeks - those who write new values on new tablets. Companions the creator seeks, and fellow harvesters; for everything about him is ripe for the harvest.

Post Reply