Page 1 of 1

Possible bug in BoundingBoxForceFieldShape class

Posted: Sat Jun 30, 2012 10:14 am
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?

Re: Possible bug in BoundingBoxForceFieldShape class

Posted: Sat Jun 30, 2012 3:20 pm
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 :)

Re: Possible bug in BoundingBoxForceFieldShape class

Posted: Sat Jun 30, 2012 4:56 pm
by Spankenstein
Ooops :)

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