HSPlasma returning empty vectors

Announcements and discussion regarding any projects related to Cyan Worlds' Plasma Engine including (but not limited to) CyanWorlds.com Engine, Drizzle, OfflineKI, PyPRP, and libHSPlasma.

HSPlasma returning empty vectors

Postby Sirius » Wed Mar 21, 2018 4:43 pm

Hello everyone,

I'm currently using HSPlasma in a C++ project, which needs to process PRPs fast (Python is not an option). You probably know what I'm talking about ;)

So I compiled my own version of HSPlasma (finally!), dynamically linked to it in my other VS project, DLL loads correctly, etc (standard stuff so far). However, there is an annoying error I'm running in, and I can't nail down what's causing it.

It seems anytime HSPlasma exposes a class property of type std::vector<class or value type> (though a getter or a public property), accessing it is impossible. Instead I retrieve some other empty vector - even when it should be returned by reference... This is very annoying for methods like plSceneNode.getSceneObjects(), or plDIInterface.fIndices. I don't think I messed up the syntax either...
Code: Select all
sceneNode->getSceneObjects().size(); // returns 0


As a workaround, I added two more methods directly inside HSPlasma's plSceneNode class:
Code: Select all
plKey& plSceneNode::getSceneObject(int id) { return fSceneObjects[id]; }
size_t plSceneNode::getSceneObjectsSize() { return fSceneObjects.size(); }

Those methods CAN access the content of the std::vector, and allow me to retrieve the objects inside the scene node. However, having to add hack functions all over HSPlasma is obviously very annoying and not desirable.

Is there something I'm missing ?
User avatar
Sirius
 
Posts: 1506
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Re: HSPlasma returning empty vectors

Postby Zrax » Fri Mar 23, 2018 6:56 pm

Hmm, I certainly haven't seen that type of behavior before in, for example, PlasmaShop (which does use those same interfaces). My first guess since the code directly exposes the `std::vector` is that you might be mixing Release libhsplasma with a Debug client application or vice versa. MSVC unfortunately uses different (non-ABI compatible) versions of many parts of STL between Debug and Release, and causes all sorts of confusing and hard to debug problems in doing so... libhsplasma makes no attempt to shield you from this, so it is important to have both a Devel and Release build if you plan on building both in the client.
User avatar
Zrax
 
Posts: 206
Joined: Fri Sep 28, 2007 5:19 pm
Location: Waist-deep in a conecano

Re: HSPlasma returning empty vectors

Postby Sirius » Sat Mar 24, 2018 7:19 am

That was it :) My program was set as Debug, while HSPlasma was compiled as Release since I figured I wouldn't need to debug that part of the code. Didn't know it would change the behavior for exposed methods.
Thanks a lot :D
User avatar
Sirius
 
Posts: 1506
Joined: Mon Jul 26, 2010 4:46 am
Location: France


Return to Plasma Development

Who is online

Users browsing this forum: No registered users and 12 guests