Hello.
I've been working on an update for my game which adds randomly/ procedurally generated maps as a treasure hunt highscore chase.
It's working rather fine technically speaking but every now and then particles appear and stay in place like sprites after an effect call (effect or effect_local, I'm not using A8's built-in multiplayer functions).
Example:
[Linked Image]

In huuuge:
[Linked Image]

Flame particles like that are emitted during a power jump with code like the following:
Code
void p_explo_chunk_fire_fade(PARTICLE *p)
{
	p.size = p.lifespan/p.skill_d*p.skill_a;
	p.vel_x *= 1-0.75*time_step;
	p.vel_y *= 1-0.75*time_step;
	p.vel_z *= 1-0.75*time_step;
	if(p.lifespan < 3 && p.skill_c)
	{
		p.skill_c = 0;
		effect(p_pogoFireTrailClouds,1,p.x,p.vel_x);
		p.lifespan = 0.25;
		p.event = NULL;
	}
}

void p_explo_chunk_fire(PARTICLE *p)
{
	p.y -= 24;
	vec_fill(p.blue,230+random(20));
	p.vel_x += random(4)-2;
	p.vel_y += random(4)-2;
	p.vel_z += random(4)-2;
	set(p,MOVE); // BRIGHT | 
	p.bmap = fireStyle3s_tga[(int)random(3)];
	p.alpha = 100; //60+random(25);
	p.size = p.skill_a = (25+random(8));
	p.skill_d = p.lifespan = 6;
	p.skill_c = 1;
	p.event = p_explo_chunk_fire_fade;
}

Notice how it should be fully opaque but that huge unwanted particle is ~50% transparent.
The same thing happened for a cloud particle where the p.size update is not relative to or at least limited in terms of lifespan:

Code
void p_pogoLandContact_fade(PARTICLE* p)
{
	vec_scale(p.vel_x,1-0.25*time_step);
	p.size = p.skill_a*minv(p.lifespan/6.0,1);   // set in spawn function: p.skill_a = p.size = (8+random(8));
}

[Linked Image]


The particles from example #1 appeared the most frequent. I use them for various particle effects though which is why I replaced them with other unique bitmaps. I've thought maybe particle events are not executed anymore for those quads but could falsify that hypothesis by drawing from that event:

Code
void p_explo_flash1_fade(PARTICLE* p)
{
	p.skill_y = p.lifespan/2.0; // in spawn/ emit/ init function: p.lifespan = 2;
	p.alpha = p.skill_b*p.skill_y*p.skill_y;
	draw_num3d(p.vel_z, p.x, 10, COLOR_RED); // p.vel_z identifies effect calls in the script at various positions, a unique ID for each call (for this specific particle effect)
}

[Linked Image]

Although I didn't print lifespan on screen I think it's safe to assume that lifespan >> 0 and that not skill_b is the issue (as the particle would disappear otherwise).


My first thought was I'm overwriting memory somewhere when I first saw that particle bug appear (and stay indefinitely on screen). However, the game hasn't crashed once since (for 16+ days now) and it can appear immediately in the first level which is loaded directly after the main function.
There's one thing though, one other visual bug and it might or might not be related:
I use(d) GPU bones animation for a bunch of stuff. Every now and then - reproducible though, it would be the same entity/-ies if I generated the dungeon with a fixed seed - entities with GPU bones animation would glitch out.
For example models like coins and goldbars had a "shine quad" in front of the main mesh, assigned to the 2nd skin (TRANSLUCENT entity flag set), vertices assigned to a different bone, and I'd rotate the coins and goldbars but keep the shiny quad in place/ unchanged or scale it down. That would work most of the time but a few coins (like one per level) would rotate twice as quickly or irregularly if more than one coin was on screen. Or the shiny quad would rotate around the origin as well or not be scaled as if it was assigned to the wrong bone. Both main and ent_mtlset shine material had the same matBones[X] code.
Some other entities with only one material and skin could become invisible, at least in the camera render pass (with the matBones material) but their shadows would show (using my custom depth shadow (material) shader/ system, thus when not using GPU bones).

As I changed all objects with said shine quad to spawn a separate shine entity each instead, only have one material and skin anymore and rotate the entity directly and not using bones the particle issues seemed to become a lot less frequent as well - although not fully gone (took me a while to make that bee show up in the previous example). Might just be a pure coincidence though. (One key model relying on a GPU bones shader still continues to show a wrong orientation every now and then.)


Sorry for this wall of text but I am very confused as where to go on with debugging that issue.
Do you have ANY idea why particles could bug out that way and maybe not have their lifespan reduced anymore? (Not sure if it's being reset instead, changing between 120fps and 12fps does not affect their size.) Btw. setting particle_mode = 1; and disabling particle instancing after seeing such a thing happen (and stay) on screen does nothing, I've tried it anyway - it shouldn't be related to drawing the particle anyway, it should be removed when lifespan reached 0 and just disappear either way.
Why would or could GPU bone animation glitch out, seemingly at random?

Thank you a lot for any advice.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends