BaseVertexPointerToElement method missing

Problems building or running the engine, queries about how to use features etc.
Post Reply
r0ut
Halfling
Posts: 44
Joined: Mon Feb 22, 2021 6:25 pm
x 2

BaseVertexPointerToElement method missing

Post by r0ut »

Ogre Version: 1.12

I'm using the C# bindings and this method is missing in VertexElement class. I've searched for it but I found an old post (https://www.ogre3d.org/addonforums/3/t-2626.html) and it didn't helped me.
Is it the SHAREDPTR issue?

Code: Select all

VertexElement posElem = vertex_data.vertexDeclaration.findElementBySemantic(VertexElementSemantic.VES_POSITION);
HardwareVertexBufferPtr vbuf =vertex_data.vertexBufferBinding.getBuffer(posElem.getSource());

byte* vertex = (byte*)vbuf.lock_(HardwareBuffer.LockOptions.HBL_READ_ONLY);
float* pReal;

for (ulong j = 0; j < vertex_data.vertexCount; ++j, vertex += vbuf.getVertexSize())
{
    posElem.BaseVertexPointerToElement(vertex, &pReal); // Missing
    Vector3 pt = new Vector3(pReal[0], pReal[1], pReal[2]);
    vMeshInf.vertices[current_offset_Vertices + j] = (nodeParentOrientation * (pt * nodeParentScale)) + nodeParentPosition;
}
vbuf.Unlock();
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: BaseVertexPointerToElement method missing

Post by paroj »

basically, yes. That function is templated and thus skipped by SWIG:
http://www.swig.org/Doc4.0/SWIGPlus.htm ... _directive

However, that function only does some trivial pointer arithmetic, that you rather should do in C#, to spare the native function call which will noticeable slow down the loop that you posted.
https://github.com/OGRECave/ogre/blob/d ... #L262-L267
r0ut
Halfling
Posts: 44
Joined: Mon Feb 22, 2021 6:25 pm
x 2

Re: BaseVertexPointerToElement method missing

Post by r0ut »

Thanks! I'll have a look into this.

Does the same applies to PSSMShadowCameraSetup.getSplitPoints()? It returns a "SWIGTYPE_p_std__vectorT_float_t"
r0ut
Halfling
Posts: 44
Joined: Mon Feb 22, 2021 6:25 pm
x 2

Re: BaseVertexPointerToElement method missing

Post by r0ut »

paroj wrote: Mon Mar 08, 2021 5:09 pm basically, yes. That function is templated and thus skipped by SWIG:
http://www.swig.org/Doc4.0/SWIGPlus.htm ... _directive

However, that function only does some trivial pointer arithmetic, that you rather should do in C#, to spare the native function call which will noticeable slow down the loop that you posted.
https://github.com/OGRECave/ogre/blob/d ... #L262-L267
Do you think this should work?

Code: Select all

private static unsafe void BaseVertexPointerToElement(void* pBase, float** pElem, VertexElement element)
{
    *pElem = (float*)((char*)(pBase) + element.getOffset());
}
Post Reply