Inside nearpoint() & nearpoints()

   1718   3   0
User Avatar
Member
103 posts
Joined: Nov. 2019
Offline
Hello!

I was wondering what is the logic inside these two function in order to rebuild them from scratch to optimize some calculations. Is it even possible to do with VEX? I am guessing that the function is very optimized and might not be as straight forward to recreate as I wished.

Thanks!
Edited by Cicuta - Dec. 22, 2023 11:56:29
User Avatar
Member
9407 posts
Joined: July 2007
Offline
I don't think you can recreate them in VEX as their build an acceleration structure that allows for faster lookup
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
34 posts
Joined: July 2022
Offline
C:\....\Houdini X.Y.ZZZ\toolkit\include\GU\GU_NeighbourList.h
User Avatar
Member
34 posts
Joined: July 2022
Offline
The function of nearpoints is roughly implemented through HDK(c++). You can find “buildPointGrid” and “buildPointTree” in GU_NeighbourList, and I guess that the optimization methods are grid and kdtree.
template <VEX_Precision PREC> static void
mynearpoints_Evaluate(int argc, void* argv[], void* data)
{
	UT_Array<VEXint<PREC>>* result = (UT_Array<VEXint<PREC>> *)argv[0];
	const char* surfaceAddress = static_cast<const char*>(argv[1]);
	VEXint<PREC>* input_pt = (VEXint<PREC>*)argv[2];
	VEXfloat<PREC>* input_maxdist = (VEXfloat<PREC>*)argv[3];
	
	GU_SopQuery quary;
	GU_ConstDetailHandle handle = quary.getDetail(surfaceAddress);
	const GU_Detail* gdp = handle.gdp();
	
	GU_NeighbourList neil;
	GU_NeighbourListParms neilp;
	neilp.setRadius(*input_maxdist);
	neilp.setOverrideRadius(true);
	neilp.setMode(GU_NeighbourListParms::InteractionMode::NONUNIFORM);
	neil.build(gdp, neilp);
	UT_Array<GA_Offset> ptlist;
	neil.getNeighbours(*input_pt, gdp, ptlist);
	
	for (GA_Index pt:ptlist)
		result[0].append(pt);
}

Attachments:
PixPin_2023-12-28_21-59-36.png (674.4 KB)

  • Quick Links