2
$\begingroup$

I come to you after days of trying to solve what should be a simple issue, but can't wrap my head arround it. I will try to be concise as I tried many many different setups, achieving parts of my goal but was not able to glue everything up correctly.

Here is the blender file :

Context : I have a node setup that makes particules bounce arround a geometry. It works nice, with different geometries or number of bouncing points.

Main objective : Flag the closest point of the collision wall on collision and keep it flagged after collision. Meaning for ex. switching an attribute state of a point of the wall to True and keep it to True after the collision.

This leads me to have the following issue :

Is it possible to easily freeze an attribute value under a certain condition, and keep it frozen, even after the collision is False again ? This is possible in simple cases but not in my main setup.

What I want : when a colision happens, the closest point of the bouncing geometry gets permanently flaged with an attribute. Idealy, this attribute can be increased temporally (like an age attribute), or just be the frame number at which the collision happens.

I initially had this setup, which works fine : when a collision happens, the closests points in the collision geometry appear :

Initial setup detecting the collision area

The bouncing points collision mouvement is not inside this node tree, I just get the point as input to the left. What I do here is change the freeze attribute when the points are in the given range. Then the points are deleted acordingly to only keep the points that were flagged. I also want to add an age attribute.

It works flawlessly, but to make it work fine, I need to have a large radius for collision detection : But it leads to having many points appearing. What I ideally want, is only the closest point to appear.

I tried adding a condition to only keep the closest one, but it does not work : the sample index need an index attribute to choose from the bouncing points. This setup does not work :

Adding condition to only keep the closest point doesn't work

After this attempt, I knew that I could make something simpler and less specific by just flag the points and do all the deleting stuff later. I though it was better as I keep the point cloud, just change the attributes, and change the point cloud later.

I made this setup that correctly flags the closest point in range, when the collision happens:

Simple multipoint setup without simulation

It works fine, for any number of points. Now I just needs to keep the points flagged. (meaning keeping the attribute state after the collision). And I was not able to figure it out. Something in my setup does not work and I do not know why : I can't merge the simulation part (keeping the attribute value) and the multi-points part (the for each part)

I tried this setup : The attribute count is intially at 0.0. When a point is flagged, it is added a value of 1, each time a collision happens. My idea was to use a simulation node after this for each setup, to just add this value of the count attribute to itself, clamping it, so I can "remember" this value over time, thus technically freezing the attribute in place.

This gave me the following setup :

Flagging then deleting setup

After the for each setup, I take my points in a simulation node setup. Inside, I add to itslef the value of 1, just like you could do for an age attribute. But I clamp it, and only do it for the "frozen" points, meaning the points where a collision happens. This should in theory, continuously keep the count attribute of points that already had a collision to a value of 1.0, allowing me to later filter those out.

But this setup does not works. It works for some points, but not all, and I cannot understand how. All the points seem to be correctly flagged (the multipoint setup seems to work fine) but after the simulation, the values are not kept correctly, and I was not able to identify what goes wrong. I did try this idea of "increasing an attribute" to keep the points that had a collision in a other and simpler setup, and it worked perfectly : (it is also in the blender file) :

Simple setup of keeping attribute frozen

But it does not work with my points main setup.

I also tried another less elegent solution, which is just putting evrything in a simulation node, effectively joining all the points each steps, and using a merge by distance node to avoid having to many points. But this cause some issues on the count attribute whose value depends on the number of points that are bouncing. (The merging dividing the attributes values I guess).

So, finally, my questions are :

  • How I am supposed to achieve this collision-detection-attribute-transfer system ? Is there a way simplier way to do it that I missed ?
  • Is it possible to freeze attribute when a condition is reached, in a simplier way that I tried ?

Thank you very much for any advice that could help this situation.

Have a great day,

$\endgroup$
2
  • $\begingroup$ Related: blender.stackexchange.com/a/308540/60486) - in there I use "Vector Math: Multiply" node to dissipate energy, what you want instead is to use a switch as in Gordon Brinkmann's answer, and set the value to current frame number if the value is 0 (it won't be confused with frame number 0 if you start your animation on frame 1), otherwise just decrease it by one. $\endgroup$ Commented Apr 22 at 20:47
  • $\begingroup$ Thank you very much for linkin this post, it helped a lot ! Using your setup and Gordon Brinkmann's switch placement, I was able to achieve my result. I added a condition to only switch if the impact point was never switched ; avoiding changing the attribute of already switched impact points. $\endgroup$ Commented Apr 24 at 19:23

1 Answer 1

2
$\begingroup$

When I started reading the question, I thought keeping the collision state at true after the first collision should not be too hard.

Let's start with state = false. Check for collision and set

state = state or collision.

At the moment when collision = true for the first time, state becomes true as well. And then it will stay true no matter what result the collision check has.

But then your question turned into a short story and I got lost and I'm not sure if this answer is sufficient.

$\endgroup$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.