Game Development Community

Having trouble debugging getBinRange() -- Bad Range! exception

by Matthew Shapiro · in Torque X 2D · 03/23/2008 (10:02 pm) · 5 replies

Here's the exception:

[External Code]	
>	Torque.dll!GarageGames.Torque.Core.Assert.Fatal(bool condition = false, string message = "SceneContainer::getBinRange() - Bad Range!") Line 31 + 0xf bytes	C#
 	Torque.dll!GarageGames.Torque.SceneGraph.SceneContainer._GetBinRange(float min = NaN, float max = NaN, out uint minBin = 0, out uint maxBin = 0) Line 748 + 0x2c bytes	C#
 	Torque.dll!GarageGames.Torque.T2D.T2DSceneContainer._GetBins(GarageGames.Torque.MathUtil.RectangleF rectangle = {GarageGames.Torque.MathUtil.RectangleF}, out uint minBinX = 0, out uint minBinY = 0, out uint maxBinX = 0, out uint maxBinY = 0) Line 188 + 0x3e bytes	C#
 	Torque.dll!GarageGames.Torque.T2D.T2DSceneContainer.CheckSceneObjectBinsT2D(GarageGames.Torque.T2D.T2DSceneObject obj = {GarageGames.Torque.T2D.T2DSceneCamera}) Line 113 + 0x3e bytes	C#
 	Torque.dll!GarageGames.Torque.T2D.T2DSceneGraph.UpdateObjectT2D(GarageGames.Torque.T2D.T2DSceneObject obj = {GarageGames.Torque.T2D.T2DSceneCamera}) Line 204 + 0xc bytes	C#
 	Torque.dll!GarageGames.Torque.T2D.T2DSceneObject.UpdateSpatialData() Line 866 + 0xc bytes	C#
 	Torque.dll!GarageGames.Torque.T2D.T2DSceneObject.Position.set(Microsoft.Xna.Framework.Vector2 value = {Microsoft.Xna.Framework.Vector2}) Line 212 + 0x7 bytes	C#
 	Torque.dll!GarageGames.Torque.T2D.T2DSceneCamera._InterpolatePosition() Line 723 + 0x2f bytes	C#
 	Torque.dll!GarageGames.Torque.T2D.T2DSceneCamera._Animate() Line 707 + 0x7 bytes	C#
 	Torque.dll!GarageGames.Torque.T2D.T2DSceneCamera.InterpolateTick(float k = 0.566666663) Line 425 + 0x7 bytes	C#
 	Torque.dll!GarageGames.Torque.Sim.ProcessList.InterpolateTick() Line 550 + 0x28 bytes	C#
 	Torque.dll!GarageGames.Torque.XNA.TorqueEngineComponent._UpdateSim(string eventName = "TimeEvent", float elapsed = 47.0) Line 787 + 0x10 bytes	C#
 	Torque.dll!GarageGames.Torque.Core.TorqueEvent<float>._Trigger(System.Delegate d = {GarageGames.Torque.Core.TorqueEventDelegate<float>}) Line 74 + 0x1d bytes	C#
 	Torque.dll!GarageGames.Torque.Core.TorqueEventManager._TriggerEvent(GarageGames.Torque.Core.TorqueEventManager.TorqueEventBase ev = {GarageGames.Torque.Core.TorqueEvent<float>}) Line 583 + 0xd bytes	C#
 	Torque.dll!GarageGames.Torque.Core.TorqueEventManager.MgrProcessEvents() Line 434 + 0xb bytes	C#
 	Torque.dll!GarageGames.Torque.Core.TorqueEventManager.ProcessEvents() Line 288 + 0x10 bytes	C#
 	Torque.dll!GarageGames.Torque.XNA.TorqueEngineComponent.Update(Microsoft.Xna.Framework.GameTime gameTime = {Microsoft.Xna.Framework.GameTime}) Line 434 + 0x5 bytes	C#
 	[External Code]	
 	Game.exe!StarterGame2D.Game.Main() Line 50 + 0xe bytes	C#

I have confirmed that this is an engine bug. To reproduce yourself all you have to do is put the following into a blank T2d starter project:

T2DSceneCamera WorldCam = new T2DSceneCamera();
            WorldCam.Name = "mainCamera";
            WorldCam.CenterPosition = new Vector2(0.0f, -40.0f);
            WorldCam.Extent = new Vector2(100.0f, 75.0f);
            TorqueObjectDatabase.Instance.Register(WorldCam);
            GUIStyle WorldStyle = new GUIStyle();
            GUISceneview WorldView = new GUISceneview();
            WorldView.Style = WorldStyle;
            WorldView.Camera = WorldCam;
            GUICanvas.Instance.SetContentControl(WorldView);
            Vector2 position = new Vector2(1.934f, 24.99f);
            WorldCam.AnimatePosition(position, 0);

It will crash out every time. Whatever bug is causing this, it is coming up a LOT for me and I need this fixed before I can finish my camera code :-/.

Anyone have any idea where I would start to look for a fix for this?

#1
03/24/2008 (5:21 am)
In,

WorldCam.AnimatePosition(position, 0);

the second parameter should not be 0. This is "The amount of time in milliseconds to allow the camera to get to the target position." With this set to 0, you end up with a divide by zero in the interpolate position code.
The code works with other values such as 2000.
#2
03/24/2008 (5:29 am)
Amazing catch Scott. We should probably have a failsafe there to allow for instantaneous movement to the spot if the second parameter is zero.
#3
03/24/2008 (6:33 am)
Hrm yeah I kind of figured 0 would mean instant.

Didn't think about a divide by zero problem though. I know it works with other values, but I'm giving it variable time to allow animating the camera towards a moving object.

That should be easy for me to temporary fix. Thanks!
#4
04/07/2009 (6:34 am)
I'm getting this same bug.
I don't have access to the engine code with my game. Is there a way that I can catch this case with an override or something? I need my game to be bug-free in a few weeks and this intermittent bug crashes it every time!
#5
04/10/2009 (10:13 pm)
Could really use some help with this one!