Vex: reverse points in a line

   747   2   0
User Avatar
Member
74 posts
Joined: Jan. 2015
Offline
In vex, I want to reverse a 2-pt line so its points switch their order (like Sort->Points->Reverse), but I can't get it to work. I tried rewiring the vertices on the existing prim, but the prim still retains its order;

int primPts[]=primpoints(0,origPrimID);
setvertexpoint(0,origPrimID,0,primPts[1]);
setvertexpoint(0,origPrimID,1,primPts[0]);

I tried creating a new prim with points in my preferred order and removing the old prim, but I still see the "wrong" point order.

int primPts[]=primpoints(0,origPrimID);
newPrim=addprim(0,"polyline",primPts[1],primPts[0]);
removeprim(0,origPrimID,1);
Edited by element33 - Jan. 18, 2023 03:42:13
User Avatar
Member
8554 posts
Joined: July 2007
Offline
Why?

It would be incredibly inefficient to try to do that in VEX

In your code all you are doing is just rewiring vertices or recreating new ones and attaching to the same 2 points
If you want to reorder points you would need to also swap all their attributes including P
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
74 posts
Joined: Jan. 2015
Offline
Found the issue: the line shared points with other prims. I had to "break out" the line by creating copied new points (which can't be fused or they'll snap back to the orig. order).
int primPts[]=primpoints(0,origPrimID);
int newPt0=addpoint(0,primPts[1]);
int newPt1=addpoint(0,primPts[0]);
pr=addprim(0,"polyline",newPt0,newPt1);
removeprim(0,origPrimID,0);
  • Quick Links