I am a complete beginner in graphics developing with XNA/Monogame. Started my own project using Monogame 3.0 for WinRT. I have this unexplainable issue that some of the vertices disappear while doing some updates on them.
Basically, it is a game with balls who collide with the walls and with each other and in certain conditions they explode. When they explode they disappear. Here is a video demonstrating the issue. I used wireframes so that it is easier to see how vertices are missing. The perfect exploding balls are the ones which are result by user input with mouse clicking. Thanks for the help.
The situations is: I draw user primitives with triangle strips using like this
graphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleStrip, circleVertices, 0, primitiveCount);
All of the primitives are in the z-plane (z = 0), I thought that it is the culling in action. I tried setting the culling mode to none but it did not help.
Here is the code responsible for the explosion
private void Explode(GameTime gameTime, ref List<Circle> circles)
{
if (this.isExploding)
{
for (int i = 0; i < this.circleVertices.Length; i++)
{
if (this.circleVertices[i] != this.circleCenter)
{
if (Vector3.Distance(this.circleVertices[i].Position, this.circleCenter.Position) < this.explosionRadius * precisionCoefficient)
{
var explosionVector = this.circleVertices[i].Position - this.circleCenter.Position;
explosionVector.Normalize();
explosionVector *= explosionSpeed;
circleVertices[i].Position += explosionVector * (float)gameTime.ElapsedGameTime.TotalSeconds;
}
else
{
circles.Remove(this);
}
}
}
}
}
I'd be really greatful if anyone has suggestions about how to fix this issue.
Remove
function doesn't completely remove something. But it's hard to tell from the video since there are so many particles and they all look the same. This issue is still happening, I would suggest adding numbers to the particles so you can see exactly which two particles explode at the end, and then go back in the video and see when they disappeared initially. Maybe they didn't even initially exist, but it's hard to tell without some way to distinguish them. \$\endgroup\$