[2.1+] MeshLodGenerator wants FLOAT3, but importV2+DearrangeToInefficient gives FLOAT4 Topic is solved

Discussion area about developing with Ogre2 branches (2.1, 2.2 and beyond)
Post Reply
rujialiu
Goblin
Posts: 215
Joined: Mon May 09, 2016 8:21 am
x 20

[2.1+] MeshLodGenerator wants FLOAT3, but importV2+DearrangeToInefficient gives FLOAT4

Post by rujialiu » Wed Apr 03, 2019 8:08 am

Hi!

When calling MeshLodGenerator with a meshv1 imported from meshv2, we got an assertion failed:

Code: Select all

    void LodInputProviderMesh::addVertexData(LodData* data, v1::VertexData* vertexData, bool useSharedVertexLookup)
    {
        if ((useSharedVertexLookup && !mSharedVertexLookup.empty()))   // We already loaded the shared vertex buffer.
        {
            return;
        }
        OgreAssert(vertexData->vertexCount != 0, "");

        // Locate position element and the buffer to go with it.
        const v1::VertexElement* elemPos = vertexData->vertexDeclaration->
                                           findElementBySemantic(VES_POSITION);

        // Only float supported.
        OgreAssert(elemPos->getSize() == 12, "");  ////////// failed here. Looks like it wants FLOAT3 for VES_POSITION
All of our v2 meshes uses HALF4 for VES_POSITION. It has a dearrangeToInefficient methods to convert from half/qtangents to floats, but it got FLOAT4 instead of FLOAT3, which MeshLodGenerator doesn't like. I tried to remove the assert and it doesn't crash anymore. We haven't finished our codes so we don't know whether the result will be ok, but it looks like the assertion should be asserting FLOAT3 OR FLOAT4 instead of FLOAT3 only?
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4044
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 216
Contact:

Re: [2.1+] MeshLodGenerator wants FLOAT3, but importV2+DearrangeToInefficient gives FLOAT4

Post by dark_sylinc » Wed Apr 03, 2019 3:09 pm

What semantic? Pos, normal or tangents?
0 x

rujialiu
Goblin
Posts: 215
Joined: Mon May 09, 2016 8:21 am
x 20

Re: [2.1+] MeshLodGenerator wants FLOAT3, but importV2+DearrangeToInefficient gives FLOAT4

Post by rujialiu » Wed Apr 03, 2019 3:47 pm

dark_sylinc wrote:
Wed Apr 03, 2019 3:09 pm
What semantic? Pos, normal or tangents?
According to the assertion code, it looks like position only. And I think when dearrange to inefficient, qtangent converts to float3 normal and float3 tangent?
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4044
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 216
Contact:

Re: [2.1+] MeshLodGenerator wants FLOAT3, but importV2+DearrangeToInefficient gives FLOAT4

Post by dark_sylinc » Wed Apr 03, 2019 3:49 pm

Nevermind, I just looked at the code and it's VES_POSITION.

Anyway, it shouldn't matter. Judging from the code, it uses an abstracted way to read from the vertex (although a bit inefficient, this is good, it can adapt to different vertex definitions), thus it just ignores the 4th element in the float.

This is also not a problem because the .w should be filled with 1.0f

I'll fix up the assert
0 x


rujialiu
Goblin
Posts: 215
Joined: Mon May 09, 2016 8:21 am
x 20

Re: [2.1+] MeshLodGenerator wants FLOAT3, but importV2+DearrangeToInefficient gives FLOAT4

Post by rujialiu » Wed Apr 03, 2019 4:07 pm

dark_sylinc wrote:
Wed Apr 03, 2019 3:49 pm
I'll fix up the assert
Thanks!! But today the MeshLodGenerator crashed on a rather big (>60MB) v2 mesh. Will try to provide more info tomorrow. I hope it handles meshes of this size (e.g. not using quadratic memory etc :P)
0 x

Post Reply