strange problem
Blitz3D Forums/Blitz3D Beginners Area/strange problem
| ||
Hi, i'm working in a project, and i have a strange problem. sometimes, the game stop rendering, only shows 2D flip. i can see text, but no 3d render. when it happens, all variables of my car change to -2147483648 what could be the problem? i tried to delete all types and create one new, but nothing. when the problem is there, i can change the cameraclscolor, but i can't see 3d objects. i using fastimage and fastext libs. what could be this problem? Regards |
| ||
hi what do you mean with: all variables? that number is the bigest negative number an integer can hold, blitz can not manage negative nmbers less than this one. (-2147483648 is 80000000 in hexadecimal notation) (asuming that your car varibles are integers) i think that this number is not a coincidence but i can't imagine why RenderWorld shows noting. I supose that if the position in 3D worl of your objects where so distant to the camera you, probaly see nothin... isnt't it? Juan |
| ||
Floating point variables can reach a value of Infinity, usually as a result of dividing by zero. They can also become NaN, which means Not a Number. This comes from nonsense calculations like Infinity/Infinity, which is likely to happen when continuing to use values which earlier became infinite. When values needed for rendering have gone bad in this way the result is that nothing is rendered. And when such floating point values are assigned to an integer variable the result is -2147483648. This is the most likely cause of your problems. Either your code or one of your libs is doing an invalid floating point calculation, with division by zero being the most common mistake. |
| ||
when (not so far away in time) i want to know if NaN's are somewhere i use (and work) : If FloatVariable="NaN" DebugLog "FloatVariable is Nan" in this way i'm sure that the problem is a NaN, even if i don't know how it reaches this value Juan |
| ||
I'm not sure if this is relevant to your issue but .. I had a similar problem and it turned out that if you use a global "helper" pivot alot of times each frame, after a while it's rotation and position turns into a "nan" and anything else which then uses it follows suit. If you print the camera position on screen, I've no doubt it will show Nan which means, assuming that your camera is offset from it, something is applying the Nan to your vehicle. To avoid this, each frame I reposition this "helper" pivot to 0,0,0 and rotated it to 0,0,0. If this doesn't help do a search for "Nan" in the forums and you'll find other possibilities. @ Charrua If FloatVariable="NaN" DebugLog "FloatVariable is Nan" I'm suprised that the test is so simple and actually works! This has been discussed before and I ended up using .. Function ISNAN( Value# ) Return ( (Value + 1) = Value ) End Function Last edited 2011 |
| ||
your test is more logial than compare a Float with a string, but that kind of things happens in Basic, isn't it? Juan |
| ||
hi!, thanks for all answers... i work hard and i found what cause the problem.. for some strange reason, the car\steer# varible of my car is modify to the value -2147483648. this happens in the loop, without a logical reason. my temporary solution is this code. last_angle# = car\steer# car\steer = car\steer * .99 ;FIX STRANGE PROBLEM (next line fix for the moment this problem) ; (sometimes, the car\steer variable changes by itself to -2147483648 if car\steer < - 300 or car\steer > 300 then car\steer = last_angle rotateentity car\wheel,0,car\steer,0 when the steer rotate -2147483648 degrees, the car desappear when the function rotateentity is execute. tomorow i'm going to try the helper method and the isnan function to see what happens. this problem reminds me of the bug i have using jv-ode with complex scenarys. now i using a very simple code loop, and i can't understand why the variable car\steer change by it self. Last edited 2011 Last edited 2011 |
| ||
Note that you can always tell if a Blitz number is integer or floating point by the way it is displayed. A floating point value has a decimal point while an integer value does not. If car\steer takes the value -2147483648 then it must be an integer. But the code last_angle# = car\steer# car\steer = car\steer * .99suggests you want it to be a float. |
| ||
i declare in the type..type car field steer# end type |
| ||
Hey S, The racing project you are working on looks truly awesome! When can we expect a beta? :) |
| ||
people... now i've found a possible causse for the error. maibe the keydown() value is the problem. my code is this car\steer# = car\steer# + keydown(203) - keydown(205) car\steer# = car\steer# *.99 now i'm using my joystik, and the problem never appears again.. can keydown() return a NaN or a crazy number? |
| ||
Don't know, but you should really parse those KeyDowns individually rather than using them inline like that. The code you posted above doesn't include any form of capping either so depending on your timing method, then that code could generate numbers which are very high, very quickly. |