Hi, if I wanted to know the number of iterations required for separation of agents with identical features,
where should I put a counter variable? In the update method? In the class Boid or in the BoidPlugin?
My plugin is very similar to Boid.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi. The issue would be whether you want a single global counter or a counter for each boid/agent. A global counter should probably be a member of the class like BoidPlugin, a per-Boid counter would be a member of the class like Boid. Both would be incremented from the update method of the same class.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thanks for the advice. I put the counter variable inside the method upadate in BoidPlugin.
void update (const float currentTime, const float elapsedTime)
{
// update flock simulation for each boid
for (iterator i = flock.begin(); i != flock.end(); i++)
{
(**i).update (currentTime, elapsedTime);
contatore++;
}
}
When I pause the application with the space, the number of iterations continues to increase. Why?
The counter variable must be inside the loop in the update method?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ah, quite so! The contatore-ing should only happen when not paused. You could get the Clock object from OpenSteerDemo and call getPausedState(), but I think it would work just as well to increment the counter only when elapsedTime is not zero:
if (elapsedTime > 0.0) contatore++;
If you are trying to count "frames" (simulation steps) you want it outside the loop. Inside the loop you are counting the total number of agent updates which is agents*frames.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I take the dot product of each agent with its neighbors. if I wanted to calculate the total number of iterations I put this counter outside the loop right?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, if I wanted to know the number of iterations required for separation of agents with identical features,
where should I put a counter variable? In the update method? In the class Boid or in the BoidPlugin?
My plugin is very similar to Boid.
Hi. The issue would be whether you want a single global counter or a counter for each boid/agent. A global counter should probably be a member of the class like BoidPlugin, a per-Boid counter would be a member of the class like Boid. Both would be incremented from the update method of the same class.
thanks for the advice. I put the counter variable inside the method upadate in BoidPlugin.
void update (const float currentTime, const float elapsedTime)
{
// update flock simulation for each boid
for (iterator i = flock.begin(); i != flock.end(); i++)
{
(**i).update (currentTime, elapsedTime);
contatore++;
}
}
When I pause the application with the space, the number of iterations continues to increase. Why?
The counter variable must be inside the loop in the update method?
Ah, quite so! The contatore-ing should only happen when not paused. You could get the Clock object from OpenSteerDemo and call getPausedState(), but I think it would work just as well to increment the counter only when elapsedTime is not zero:
if (elapsedTime > 0.0) contatore++;
If you are trying to count "frames" (simulation steps) you want it outside the loop. Inside the loop you are counting the total number of agent updates which is agents*frames.
I take the dot product of each agent with its neighbors. if I wanted to calculate the total number of iterations I put this counter outside the loop right?