New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Codechange] Allow snowball effect truck activation #1190

Merged
merged 2 commits into from Oct 19, 2016

Conversation

Projects
None yet
2 participants
@ulteq
Contributor

ulteq commented Oct 19, 2016

This automatically activates all trucks which might soon get hit by any moving truck in the scene.

@ulteq

This comment has been minimized.

Show comment
Hide comment
@ulteq

ulteq Oct 19, 2016

Contributor

But what if you build a tower of paper boxes and then shoot it with a tennis-ball cannon?

@only-a-ptr, this should work now.

The graph is still fine, but you'll need one per each moving element. Falling boxes may wake up other boxes.

Falling boxes now wake up other boxes.

Under these circumstances, both caching and AABB efficiency come back to play.

We still do not check any edge twice.

Contributor

ulteq commented Oct 19, 2016

But what if you build a tower of paper boxes and then shoot it with a tennis-ball cannon?

@only-a-ptr, this should work now.

The graph is still fine, but you'll need one per each moving element. Falling boxes may wake up other boxes.

Falling boxes now wake up other boxes.

Under these circumstances, both caching and AABB efficiency come back to play.

We still do not check any edge twice.

@ulteq ulteq added this to the 0.4.7.0 milestone Oct 19, 2016

@only-a-ptr

only-a-ptr requested changes Oct 19, 2016 edited

Thanks for looking into it, but I'm not sure it will work as intended.

Also I don't like the function renaming, see below
[ulteq] Agreed, I reverted it.

Show outdated Hide outdated source/main/physics/BeamFactory.cpp Outdated
for (int t=0; t<m_free_truck; t++)
{
if (m_trucks[t] && m_trucks[t]->state == SIMULATED && m_trucks[t]->sleeptime == 0.0f)
this->RecursiveActivation(t, visited);

This comment has been minimized.

@only-a-ptr

only-a-ptr Oct 19, 2016

Member

Unless I'm missing something, this call won't have any effect because all trucks were already visited.

@only-a-ptr

only-a-ptr Oct 19, 2016

Member

Unless I'm missing something, this call won't have any effect because all trucks were already visited.

This comment has been minimized.

@ulteq

ulteq Oct 19, 2016

Contributor

Only the trucks reachable from current_truck were already visited.

This new for-loop adds root nodes to the graph.

@ulteq

ulteq Oct 19, 2016

Contributor

Only the trucks reachable from current_truck were already visited.

This new for-loop adds root nodes to the graph.

This comment has been minimized.

@only-a-ptr

only-a-ptr Oct 19, 2016

Member

I've re-read the code and this is what I got: the RecursiveActivation(truck) marks the truck immediately as visited: https://github.com/ulteq/rigs-of-rods/blob/f45980ccabb3a921be1f283024a7f52dfd72babc/source/main/physics/BeamFactory.cpp#L568

Hence:

  1. RecursiveActivation(curr_truck) marks curr_truck visited. EX: curr_truck is a tennis-ball cannon.
  2. The loop inside will traverse ALL other trucks: https://github.com/ulteq/rigs-of-rods/blob/f45980ccabb3a921be1f283024a7f52dfd72babc/source/main/physics/BeamFactory.cpp#L570 and mark them visited. EX: other trucks are paperboxes not touching the cannon - marked visited and no intersect. detected.
  3. The snowball pass will do nothing.
@only-a-ptr

only-a-ptr Oct 19, 2016

Member

I've re-read the code and this is what I got: the RecursiveActivation(truck) marks the truck immediately as visited: https://github.com/ulteq/rigs-of-rods/blob/f45980ccabb3a921be1f283024a7f52dfd72babc/source/main/physics/BeamFactory.cpp#L568

Hence:

  1. RecursiveActivation(curr_truck) marks curr_truck visited. EX: curr_truck is a tennis-ball cannon.
  2. The loop inside will traverse ALL other trucks: https://github.com/ulteq/rigs-of-rods/blob/f45980ccabb3a921be1f283024a7f52dfd72babc/source/main/physics/BeamFactory.cpp#L570 and mark them visited. EX: other trucks are paperboxes not touching the cannon - marked visited and no intersect. detected.
  3. The snowball pass will do nothing.

This comment has been minimized.

@ulteq

ulteq Oct 19, 2016

Contributor

The loop inside will traverse ALL other trucks

No. Only those with intersecting bounding boxes.

The snowball pass will do nothing.

Visited trucks can be visited again. Just not recursively from RecursiveActivation.

@ulteq

ulteq Oct 19, 2016

Contributor

The loop inside will traverse ALL other trucks

No. Only those with intersecting bounding boxes.

The snowball pass will do nothing.

Visited trucks can be visited again. Just not recursively from RecursiveActivation.

This comment has been minimized.

@only-a-ptr

only-a-ptr Oct 19, 2016

Member

No. Only those with intersecting bounding boxes.

Right. My mistake.

Visited trucks can be visited again. Just not recursively from RecursiveActivation.

From where, then? The snowball pass uses RecursiveActivation() only. But my tennisball-gun scenario will work, yes.

@only-a-ptr

only-a-ptr Oct 19, 2016

Member

No. Only those with intersecting bounding boxes.

Right. My mistake.

Visited trucks can be visited again. Just not recursively from RecursiveActivation.

From where, then? The snowball pass uses RecursiveActivation() only. But my tennisball-gun scenario will work, yes.

This comment has been minimized.

@ulteq

ulteq Oct 19, 2016

Contributor

The this->RecursiveActivation(t, visited); calls inside of the RecursiveActivation function will never be called if t was visited before.

From where, then?

From the snowball effect for-loop.

@ulteq

ulteq Oct 19, 2016

Contributor

The this->RecursiveActivation(t, visited); calls inside of the RecursiveActivation function will never be called if t was visited before.

From where, then?

From the snowball effect for-loop.

This comment has been minimized.

@ulteq

ulteq Oct 19, 2016

Contributor

The snowball pass will do nothing.

I just noticed that the snowball pass does more than needed.

this->RecursiveActivation(t, visited); does not need to be called if visited[t] == true.

@ulteq

ulteq Oct 19, 2016

Contributor

The snowball pass will do nothing.

I just noticed that the snowball pass does more than needed.

this->RecursiveActivation(t, visited); does not need to be called if visited[t] == true.

ulteq added some commits Oct 19, 2016

[Codechange] Allow snowball effect truck activation
Automatically activates all trucks which might soon get hit by any moving truck in the scene

@ulteq ulteq merged commit 69698ae into RigsOfRods:master Oct 19, 2016

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@ulteq ulteq deleted the ulteq:improved-truck-state-update-routine branch Oct 19, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment