Possible bug in BoundingBoxForceFieldShape class

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Spankenstein
Posts: 249
Joined: Wed Nov 17, 2010 1:49 pm

Possible bug in BoundingBoxForceFieldShape class

Post by Spankenstein »

The 'BoundingBoxForceFieldShape' class in the source has the following method:

Code: Select all

        
public override IList<Entity> GetPossiblyAffectedEntities()
        {
            affectedEntities.Clear();
            ForceField.QueryAccelerator.GetEntries(BoundingBox, affectedEntries);
            for (int i = 0; i < affectedEntries.count; i++)
            {
                var EntityCollidable = affectedEntries[i] as EntityCollidable;
                if (EntityCollidable != null)
                    affectedEntities.Add(EntityCollidable.Entity);
            }
            affectedEntries.Clear();          // ERROR?!
            return affectedEntities;
        }
afftectedEntries is cleared before returning, this doesn't appear to be what was intended?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Possible bug in BoundingBoxForceFieldShape class

Post by Norbo »

The AffectedEntries list gets cleared, and the AffectedEntities list gets returned. The entries list doesn't need to be kept around since not all entries are entities, and all the entities have been extracted already.

That similarity puzzled me for a while too :)
Spankenstein
Posts: 249
Joined: Wed Nov 17, 2010 1:49 pm

Re: Possible bug in BoundingBoxForceFieldShape class

Post by Spankenstein »

Ooops :)

Now I see. Thought I'd read it correctly too but alas no.
Post Reply