Debugging Fun!

Blitz3D Forums/Blitz3D Programming/Debugging Fun!

Black Hydra(Posted 2005) [#1]
If you understand the sarcasm in my post you know that debugging is anything but fun. Worse is when you have an error that occours very infrequently, appears seemingly at random and does not appear to be triggered by any specific piece of code. I'm stuck with one of those right now.

After a few hours looking at it I figure it can't hurt to have someone else maybe give some insight.

Here it is:
In my game several of my enemies use the same model (more are made through CopyEntity() ) the only difference being the brush they use and their size. Whats happening is that the models appear to be switching between brushes seemingly at random and only for a second at most.

Notes:
Aside from the original PaintEntity during setup I don't Paint any of them in my main code loop. So it would *seemingingly* be impossible for them to spontaneously change color (brushes) back and forth.

While I can't verify this, (it takes me a few minutes of testing before I can recreate the error) the error does appear to occour during camera angle shifts. Note that the color change is a complete change from one to the other, there is no stretched lines that might occour if one had several, different colored entities all occupying the same space as a result of the z-buffer.

So, does anyone have any idea what might cause this spontaneous shift in brush color? I'll post some code snippets (I'm sure you don't want to look through the entire 3000+ lines). Bear in mind these are relevant snippets of the actual code that involve the use of meshes and brushes.

ENEMY CREATION CODE:


ENEMY COPYING CODE

ENEMY SPAWNING CODE

Thank you for your help!


Danny(Posted 2005) [#2]
Hard to see from a quick look at your code,

But.. what you describe 'could' happen when you have two exactly the same entities/meshes at EXACTLY the same position and rotation - but with different materials/brushes.

Sometimes you'll get a nasty noise on the textures or material flipping like you describe because the camera doesn't know wich entity to prioritize over the other (cause the polygons occupy the EXACT same space-but with different attributes).

So, I can imagine that you somewhere accidently create 2 copies of an entity without knowing it, or forget to move one away. Especially since you say it seems to happen when the camera angle changes....

Hope this makes sense, not sure if it i'll help in your case..
D.


BlackJumper(Posted 2005) [#3]
Following what Danny said...

Is it possible in your movement/AI code for an enemy to be stationary for long enough to spawn another enemy in exactly the same location ? If two enemies then got 'triggered' to start moving, and if they share deterministic (i.e. non-random) AI code, then you could get the effect described.


Black Hydra(Posted 2005) [#4]
Well I doubt that this is a result of double entities for the following reasons:

1) There is no z-buffer distortions. The entity simply changes color comletely.

2) The enemies appear to change between several different patterns and I cannot seem to control when it occours. For example one enemy I had and faced, it would switch between more than one texture.

The hardest part of this error is the difficulty I'm having replicating it. It takes a few minutes of testing for the error to occur and it happens almost randomly. Does anyone have any other ideas at what could trigger a spontaneous brush change?

@jumper - no, there wouldn't be a double spawn problem. The SpawnEnemy() function I have positions enemies separately. If there was a problem it would be due to having multiple entities in the same location all parented to the Offset Pivot so they got moved along the same, and thus being the same enemy for code purposes. However given my forementioned reasons I doubt this is the case.

Thanks for your help...


DJWoodgate(Posted 2005) [#5]
The only paintentity I can see in the above code has been commented out. Anyway as Glagar is essentially a hierarchy painting just the top level of that hierarchy is a bit suspect, as it will contain as many brushes as there are surfaces for each entity in the hierarchy, so maybe that is why you are not doing it like that. I guess I am missing something. The brush system in blitz can be a bit of nightmare, what with entity brushes and surface brushes on the actual mesh and of course the fact that exactly how they interact is not documented.


Black Hydra(Posted 2005) [#6]
So what do you suggest I do?

I'm a little confused at what you believe I've done wrong. The PaintEntity command applies the brush to ...Glagar/HandleNum. The HandleNum is a pointer to the entity so I don't see what the problem is with that...
Is there something wrong with my doing this?

I was doing a bit of testing by changing the alpha levels of the enemies (I figure if there are multiple enemies being drawn, an alpha level change will quickly point out that there is more being drawn then should be). Hopefully this will lead me to a solution.

Debugging is never fun...


Black Hydra(Posted 2005) [#7]
Gah! Its gotten worse.

Now when I have my entities alpha set to .5 they pop in and out of view depending on camera angles. Worse yet it seems these camera angles are random (perhaps based on position not camera angle, I'll have to check). I suspect my problem is linked to this.

However, since I have no HideEntity code or EntityAlpha 0 code that runs for my enemies I can't even see how it is possible that they could come in and out of view like that.

Please, if anyone can help me I beg of you. I'm really stuck here...


Black Hydra(Posted 2005) [#8]
Okay I have a lead I'm working on.

I've figured out the logic to the apparent randomness at which the slightly transluscent (.85 Alpha) enemies automatically snap out of view.

This appears to be caused when I can see the second enemy...

I set up my experiment so that there were two enemies. Now it appears that the first is invisible as long as I can see the second.

This is pretty wacky, however I did notices something.

If I use a different enemy (one with a different mesh) for my experiment, or if I reload the mesh for the other enemy I can see both at the same time with no problems. This makes me think this may be a bug with my CopyEnemy code in which the copied entity still maintains some link to the original causing these weird glitches...

Any ideas?


Graythe(Posted 2005) [#9]
I had what seemed a similar problem when I applied LightMesh to entity handles created with CopyEntity. Try using CopyMesh to create a totally independant new entity.


jfk EO-11110(Posted 2005) [#10]
This Alpha Behaviour reminds me of some problems I had some time ago. In the first place I blamed Blitz in the Bug Reports, but the problem disappeared when I updated my radeon 9200se's Catalyst driver.

I had terrain troubles (any meshes would lose their brush while the terrain was out of the FOV of the camera), as well as the following alpha problem: all Alpha-Objects disappeared as long as there have been ONLY semi-translucent objects in the scene, so I had to add a fully opaque mesh somewhere to make sure the alpha stuff was rendered at all. And there where a few more strange alpha artifacts.