Closed 0x5143 closed 1 year ago
Final I found is postmetric
is NaN, because of NaN of child
(Max
and Min
are all NaN) in below code:
struct Tree
{
unsafe float RefitAndMeasure(ref NodeChild child)
}
In the CharacterDemo? Could you provide the modified version that reproduces the problem?
new 1000 SponsorCharacterAI
in Demos.Demos.Characters.CharacterDemo
, like below
const int characterCount = 1000;
characterAIs = new QuickList<SponsorCharacterAI>(characterCount, BufferPool);
var characterCollidable = Simulation.Shapes.Add(new Capsule(0.5f, 1f));
for (int i = 0; i < characterCount; ++i)
{
var position2D = newtArenaMin + (newtArenaMax - newtArenaMin) * new Vector2(random.NextSingle(), random.NextSingle());
var targetPosition = 0.5f * (newtArenaMin + (newtArenaMax - newtArenaMin) * new Vector2(random.NextSingle(), random.NextSingle()));
characterAIs.AllocateUnsafely() = new SponsorCharacterAI(characterControllers, characterCollidable, new Vector3(position2D.X, 5, position2D.Y), targetPosition);
}
Just adding a bunch of characters like that doesn't reproduce a crash after about an hour of idling. Attempting to update them does if there are no newts, because SponsorCharacterAI
expects a nonzero number of newts, but that should be a pretty instantaneous crash.
What other changes were made to the CharacterDemo
, if any? And is this using the latest master version?
Comment code associated with newt
like below, and remove spooked condition let it jump sometimes:
//for (int i = 0; i < newts.Count; ++i)
//{
// ref var newtPosition = ref simulation.Bodies[newts[i].BodyHandle].Pose.Position;
// var offset = newtPosition - body.Pose.Position;
// var distance = offset.Length();
// if (distance > 1e-10f)
// {
// var influenceMagnitude = 1f / (distance * 0.1f + .1f);
// influenceSum -= new Vector2(offset.X, offset.Z) * influenceMagnitude / distance;
// }
// if (distance < 20)
// {
// spooked = true;
// }
//}
////We want target position relative influence to be consistent regardless of newt count.
//influenceSum /= newts.Count;
then CharacterAI will move and jump.
I has tested in the master code and v2.4.0, have the same exception.
The sponsors AI also relied on the newts being around to provide nonzero movement influence; if they reach the final target, there will be a divide by zero. Went ahead and guarded against it in 22dac469c92e5ffbeb3764feedb9eb90326361ac.
Thanks reply. I have tested for a long time and not exception, it look work well.
I create 1000 SponsorCharacterAI in CharacterDemo, after a little minutes it will cause exception below: