In game mesh edit. Polygons become invisible at specific angle

I’ve been playing around with mesh edit in game engine and noticed some unexpected behavior.

Polygons become invisible at specific angle (depends on how vertices been rearranged?) even though camera is looking at “top” side of polygon as shown in pictures.

On original mesh all polygons are triangles with normals pointing to z+ axis, I rearrange them into cube.

This only seem to happen then looking at the bottom of cube, not top.

Any ideas why this happens? Or how to fix it?

Note that changing vertex normals only affect shading, not which side of polygon is visible.

Try disabling back face culling in the material settings.

Make sure the objects center is still near the center of the actual object, otherwise the camera off-screen culling won’t work, making things vanish.

They still disappear, though when looking “inside” cube back side does become visible.

Still happens even if newly added cube is near center, but only if the rest of polygons are further away (because off screen?).

Is there any other way to fix such object disappearing?

I think Raco is the expert on this? Someone brought this topic up a few years back, but I can’t remember who.

Anyway, things you can try (bear in mind I haven’t tried any of this):

  • KX_Camera has a boolean value 'frustrum_culling’, try setting it to False (Caution, will greatly increase load on rasterizer)
  • Make the object really big in the viewport, and make sure when you modify it in-game, it only gets smaller

Solarlune said here:

You can force an object to be visible by setting its visible property to True every frame, or by placing vertices very far apart so that the camera is always looking at part of its bounding box.

###################################### becau message deleting is not a thing :slight_smile:

Disabling frustum_culling doesn’t solve problem.

Making mesh huge works, but it just hides problem.

Setting visible property to True on every logic tick works as expected (doesn’t work when called only on every frame - frequency 1).

A mix of those solutions could be the best solution:

  1. making mesh reasonably big
  2. setting visible property to True if re-meshed part goes beyond original bounding box

Thanks for help

–> that is your problem. You moved the mesh outside of its original bounding box. The frustum culling is based on the original bounding box, not whatever you changed it to. Either you ensure you do not exceed the original bounding box or you refresh it.

Can it be refreshed inside bge? Can’t find function for that.

If you were talking about reinstancePhysicsMesh that doesn’t stop mesh from becoming invisible.

This updates the model the physics engine sees. I do not know if there is an option to update the bounding box. It would be a nice addition.