RenderWorld causes MAV

Blitz3D Forums/Blitz3D Beginners Area/RenderWorld causes MAV

K(Posted 2011) [#1]
Hello, as simple as that. I hate to post this here but I'm stuck.What it is is two internally rendered cutscenes; these particular two crash partway along through the cutscene, typically about one frame from the end.Outside of those vids, the render works fine. And..
1)I have not exceeded the poly limit, not even close.
2)There is a sprite involved in one of the videos so I tried removing it and it still MAV'd.(so not the usual culprits)
3)To complicate matters, once only the second cutscene made it through all the way, but then the main loop MAV'd on the first cycle.

Please help,and thank you in advance.
-K

Last edited 2011


jfk EO-11110(Posted 2011) [#2]
MAV with debug on?


Stevie G(Posted 2011) [#3]
Assuming you have debug on, another possible issue is that one of your entity handles is using a float instead of an int. I had this issue a while back and everything worked fine on XP, but not on more recent OS's.


Warner(Posted 2011) [#4]
If you can't get it fixed, maybe you could recreate and isolate the problem in a small test. Usually that clarifies what the core problem really is. Then, you could consider posting that as an example.


K(Posted 2011) [#5]
4)Happens with Debug off.
5)Fixed first one by deactivating the main cam and re-activating after, but second one plays through and then still repeats #3 above.
6)@Stevie: yes...I do have float handles but never caused problems before. I'm running on XP, but I'll keep that in mind for the future. Actually, the cutscene itself only uses int handles.

okay, here goes,it's been VERY trimmed down to the vid itself...


("sav" is an entity passed into the vid() func)


jfk EO-11110(Posted 2011) [#6]
No mav here. (No error with Debug on ???)

Slightly edited so it can be run:
Graphics3D 800,600,32,2
SetBuffer BackBuffer()

player1cam=CreateCamera()
player1entity=CreateCube()
sav=CreateSprite()

CameraProjMode player1cam,0
camv=CreateCamera()
time=300
ShowEntity sav
While time>9
 Cls
 Delay 26
 time=time-1

 PointEntity camv,player1entity
 MoveEntity player1entity,0,Rand(-1,1),Rand(-1,1)
 ScaleSprite sav,9*Rnd(.2,1),9*Rnd(.2,1)

 RenderWorld
 UpdateWorld()
 Color 0,0,0
 Rect 0,0,800,35,1
 Rect 0,565,800,35,1
 Color 255,255,255
 Flip

Wend
FreeEntity camv
CameraProjMode player1cam,1
;Return 1


Some points:

-Why do you use Updateworld AFTER Renderword, it's meant to be used before.
-If the mav happens with Debug off, but there's no error with debug on, then make sure there is no access to array indicies outside of the array, as well as access to a bank with a negative or a too high peek/poke index.
-Stop using sprites, use a sprite substitute, see code archives
-Never use floats as handles
-Make sure not to use a freed entity: it still can be used, but it might be removed with the next allocation of new content by directx. Solution: "Freeentity E:E=0"


K(Posted 2011) [#7]
@JFK: For some bizaare reason, putting UpdateWorld() after the render causes the first vid to work perfectly; after it statred at this I started shufffling lines around `til I got results. No effect whatsoever on the second one. Second crashe regardless of Debug. Working on it now...

EDIT:On windowed mode, if I block the window and then look, the player's gun is there against black screen. Probably irrelavent

Last edited 2011


Zethrax(Posted 2011) [#8]
6)@Stevie: yes...I do have float handles but never caused problems before. I'm running on XP, but I'll keep that in mind for the future.

Well that's pretty much an epic fail right there. Floating point numbers store data in the same 32 bits as integers, but have to use some of those bits for the exponent, etc. As a result they can't store as wide a range of values, so the value you store in a float variable may not be the same as the value you pull out of the float variable when you need to use it as a handle value. Since most handles are memory addresses, if they're not precisely the right number then you will get some hairy results.


K(Posted 2011) [#9]
Okay, Bill, I'll get on that, but there are none in this case. Sat up til midnight on this.I'm running 16-bit color if that's important,

Last edited 2011


Warner(Posted 2011) [#10]
Try posting a working sample that shows the bug. Maybe it is system dependant? It would be best if others can reproduce the problem in order to help you solve it.


K(Posted 2011) [#11]
Okay dudes, fixed it, two different ways

vid1: deactivateing main cam,not running Md2 anims(didn't mention that in the example earlier),placing UpdateWorld after render.
vid2: using main cam instead of vidcam(camv), not running Md2 anims.

Why either thing works is a mystery to me. Been working on this accross lunch at work and finally got it.Sorry about my example A)not reproducing the bug, figured it would since I copied direct from my source file, and B) forgetting to add Graphics3d etc. Thanks for the pointers, I'm gettin' to eliminating FloatHandles and Sprites. Thank you also for your patience with my idiocy.

I would also like to thank my parents, and my dog, special thanks to Tony Blair for having a humourous name...


EDIT: What gets me is I've made literally a hundred+ cutscenes on nearly identical code, and they never crashed on RenderWorld.

Last edited 2011


jfk EO-11110(Posted 2011) [#12]
I see in both fixes you did "not running MD2 anims" - maybe the md2 are the cause?


K(Posted 2011) [#13]
That's what I wonder, but again, never caused trouble in the other cutscenes.
I just started commenting lines out until I found combos that didn't MAV. Boggles me too that except the MD2s (Which I hate anyway), none of the fixes had parrallels, when the coding for the cutscenes at first was nearly identical.
This

PointEntity camv,player1\entity
MoveEntity player1\entity,0,Rand(-1,1),Rand(-1,1)
ScaleSprite sav,9*Rnd(.2,1),9*Rnd(.2,1)

and this

If time>20TurnEntity camv,0,1,0TranslateEntity sav,0,0,1 ElsePointEntity camv,sav
If time=<20TranslateEntity sav,0,-1-(20-time),.4

were the only parts to be different.

Last edited 2011


jfk EO-11110(Posted 2011) [#14]
BTW personally I would not use more than one command between if and else, as in your one-line if-else construct. Maybe it works, but I'd suggest to use a more bulletproof construct for any IFs. Adding Then and Endif at the right places, will make this more stabile and also more portable:

If time>20 then : TurnEntity camv,0,1,0 : TranslateEntity sav,0,0,1: Else: PointEntity camv,sav : endif

THere are also some problems with IF conditions that are not put in brackets, eg.:

If a=1 and B=2

first "1 and B" will produce true or false, depending on B, so if a=(1 and B)=2 is not really what you want. To be on the secure side, use brackets:

If (a=1) and (B=2)

Additionally, although you only need one float in a calulation to make Blitz use Floats for the whole calculation, I would suggest to use Floats for all numbers:
ScaleSprite sav,9.0*Rnd(0.2,1.0),9.0*Rnd(0.2,1.0)

These are some of the things that I do when I can't find a bug. BTW is "time" an INT in your code, or is it a float? Is it maybe NAN or something, when counted down to zero? (print time !)