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

http://img137.imageshack.us/img137/7074/gmconstruct0000g.jpg[/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?

[media]http://img260.imageshack.us/img260/7599/gmconstruct0000copy.jpg

…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.

EDIT:

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 gmod.org?
I’ve generated entire landscapes with PhysicsFromMesh() and not once had a problem, however the old mesh drawing codes and known to have problems.

[editline]12:22AM[/editline]

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

[editline]12:24AM[/editline]

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

[editline]12:27AM[/editline]

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

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

-snip- Moved to above post

cl_init.lua

[lua]
function ENT:Initialize()

    self.mesh = NewMesh()
    self.mesh:BuildFromTriangles(self.triangles)

end

function ENT:Draw()

self:DrawModel()

local matrix = Matrix()

matrix:SetTranslation(self:GetPos())
matrix:Rotate(self:GetAngles())

render.SetMaterial(mat)
	
cam.PushModelMatrix(matrix)
	
	self.mesh:Draw()	
cam.PopModelMatrix()

end
[/lua]

init.lua

[lua]
self:PhysicsFromMesh(self.triangles)
[/lua]

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.

[editline]07:10PM[/editline]

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^^

[editline]07:11PM[/editline]

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

[editline]07:19PM[/editline]

: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?

[editline]01:09PM[/editline]

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.