Extra number value in array?

   1330   4   1
User Avatar
Member
97 posts
Joined: May 2015
Offline
So im getting alot of 0's inside a foreach loop when i store a value into an array,Why? Is there a way to just get the points i got inside the nearpoints function. I dont want to use removevalue function cause if i get a point in the array 0 i dont want to remove it.

vector lastpoint = point(0,"P",28);
vector pos = point(0,"P",25);
int area[] = nearpoints(0, pos,0.31);
f[]@distancenum;
i[]@areanum;

foreach(int p; area)
{
  setpointgroup(0,"TEST",p,1);
  
  vector currentpos = point(0,"P",p);
  float distancepoint = distance(lastpoint,currentpos);
  @distancenum[p] = distancepoint;
  @areanum[p] = p;
  
  
}  
Edited by Shadowjonny - June 17, 2019 04:57:15

Attachments:
Screenshot (346).png (355.3 KB)

User Avatar
Member
4491 posts
Joined: Feb. 2012
Online
That's normal because you are assigning values into an array by index so the gaps are filled with 0s.

You can just store the resulting array like so:

i[]@pts = area;
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
User Avatar
Member
97 posts
Joined: May 2015
Offline
animatrix3d
That's normal because you are assigning values into an array by index so the gaps are filled with 0s.

You can just store the resulting array like so:

i[]@pts = area;

Works for inter not float? distancenum is float when i do @distancenum = area; I get {25.0,1.0,2.0,4.0,5.0}, i want to store the values i get from distancepoint.
Edited by Shadowjonny - June 17, 2019 06:36:57
User Avatar
Member
11 posts
Joined: Dec. 2013
Offline
use
append(@distancenum,p)
instead
User Avatar
Member
97 posts
Joined: May 2015
Offline
ThomasRunning
use
append(@distancenum,p)
instead

OMG!! of course that would work how did i forget about that function. -.- Thank you.
  • Quick Links