PhysicsFromMesh problem(gmod bug?)

I’ve been messing around with PhysicsFromMesh lately, and I noticed an oddity; one of the corners of my box clipped the world/ other objects.
I rewrote the code and narrowed the problem down and this is what I found[/media]

Worth mentioning is that the wireframe you see above the physics use the same shared vertex table, so you’d think the physics would be the same?


…but no, the red lines show what the actual physics look like.

Here are the positions of the corners (the same order they were stored in the table)

0 -5 50
-50 -5 0
-50 5 0

To me this seems like a problem with PhysicsFromMesh, since the drawing works, but not the physics.

Note: this also occur with garrys mesh test stool.

And don’t ask for code, you won’t get it.

Yeah because we can totally rule out a code fuck up when you won’t let us see it?
I’ve used this function heaps of times and never had this problem.

I didn’t notice it at first. Try this: spawn the entity using this function and test if all of the corners collide with the ground. And being a coder myself, I choose not to give the code since both the physics and rendering are given the same vectors, but give different outcomes, thus it’s a gmod bug.


Also, FYI I spent 3-4 h debugging before I posted this thread to make sure it wasn’t my code that was fucked.

Because someone will steal your cube rendering code that already exists on
I’ve generated entire landscapes with PhysicsFromMesh() and not once had a problem, however the old mesh drawing codes and known to have problems.


Plus your pictures are difficult to understand what’s going on…


and you mention narrowing the code down? what did you narrow the code down to?


or more to the point why not use that code from the box rendering or mesh primitives on to check your code?

Even the best coder in the world can make a mistake they constantly overlook.

-snip- Moved to above post


function ENT:Initialize()

    self.mesh = NewMesh()


function ENT:Draw()


local matrix = Matrix()






There you have the important parts. As you can see the rendering and physics both use self.triangles which is generated from a function in shared.lua

And don’t tell me to show that function 'cause it’s not related to the problem in any way since the rendering is correct. Only the physics don’t work even though the function recives the exact same triangles as the rendering mesh.


The white lines are what’s rendered in gmod, and the red lines (made in MS paint:smug:) are what the shape of the actual phys mesh is, so basically point 1 and 3 are correct where as point 2 has been moved to the entitys origin. Hope you understand better now^^


I can make a video of the problem if you want.


:eek:How dare you:argh:

So PhysicsFromMesh works now? Can players actually walk on it?

Also, I don’t think we can help you unless you show us how you build your triangles.

Oh no, physics from mesh with players is still horrible and likely to kill the player walking upon it.

Are you allowing for prediction?


It’s a shared function so to avoid glitches it’s best to have it called on both the server and cleint to allow for prediction.