Slow access to GU_Detail within custom C++ function for VEX!

   823   0   1
User Avatar
Member
209 posts
Joined: March 2018
Offline
Hello everyone!
I have a quite simple C++ code:
#include <iostream>
#include <VEX/VEX_VexOp.h>
#include <OP/OP_Director.h>
#include <SOP/SOP_Node.h>
#include <GEO/GEO_Primitive.h>
#include <GEO/GEO_PrimVolume.h>
#include <UT/UT_Lock.h>
static UT_Lock theMutex;
template <VEX_Precision PREC>
static void
wetmap(int, void *argv[], void *)
{
//UT_Lock::Scope lock{theMutex};
VEXvec3<PREC> *resultCd = static_cast<VEXvec3<PREC>*>(argv[0]);
const char *surfaceAddress = static_cast<const char *>(argv[1]);
VEXvec3<PREC> *P = static_cast<VEXvec3<PREC>*>(argv[2]);
VEXvec3<PREC> color{*P};
SOP_Node* surfaceNode = OPgetDirector()->findSOPNode(surfaceAddress);
OP_Context context{CHgetEvalTime()};
GU_DetailHandle geo = surfaceNode->getCookedGeoHandle(context);
// const GEO_PrimVolume* volume = static_cast<const GEO_PrimVolume *> (geo.gdp()->getGEOPrimitive(0));
// color = volume->getValue(*P, volume->getVoxelHandle());
*resultCd = color;
}
void
newVEXOp(void *)
{
using UT::Literal::operator""_sh;
new VEX_VexOp("wetness@&VSV"_sh,
wetmap<VEX_32>,
wetmap<VEX_64>
);
}
The problem is that calling wetness from a wrangle in Houdini is really slow but if I uncheck Enable Multithreading in VOP it runs almost fine!
Can anyone help me please?
Thank you so much!
  • Quick Links