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.
Post Reply
User avatar
Sirius
Posts: 1508
Joined: Mon Jul 26, 2010 4:46 am
MOULa KI#: 0
Location: France

HSPlasma returning empty vectors

Post by Sirius »

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
Zrax
Posts: 206
Joined: Fri Sep 28, 2007 5:19 pm
MOULa KI#: 0
Location: Waist-deep in a conecano
Contact:

Re: HSPlasma returning empty vectors

Post by Zrax »

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
Sirius
Posts: 1508
Joined: Mon Jul 26, 2010 4:46 am
MOULa KI#: 0
Location: France

Re: HSPlasma returning empty vectors

Post by Sirius »

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
Post Reply

Return to “Plasma Development”