Scaling physics mesh issues

Hi, I’ve been trying to scale the collision mesh (PhysObj) and have found this to work:


local xPhysObj = xEntity:GetPhysicsObject()
		local xMesh = xEntity:GetPhysicsObject():GetMesh()
		for k,v in pairs( xMesh ) do
			v.pos = v.pos * fScale
		end
		
		xEntity:PhysicsFromMesh( xMesh )
		xEntity:EnableCustomCollisions()

The big problem with , is if you collide them with stuff or “grind push” against other entities, this will create alot of collisions which lagg/jerk up the server.

So yea… Advice?

Thats because PhysicsFromMesh constructs a concave object which is really laggy to do collision testing against, this cant be solved unless garry adds the functions required (GetMesh function returning each convex)

g

Wont work
garry needs to provide a physics function that returns convex
If you want you can use PhysicsFromMeshConvex though, but it will breaks “hollow” props

Here this works:
aTempConvex[0] = Vector( -5.906250, -5.906250, -5.906250 )
aTempConvex[1] = Vector( -5.906250, -5.906250, 5.906250 )
aTempConvex[2] = Vector( 5.906250, 5.906250, 5.906250 )
aTempConvex[3] = Vector( 5.906250, -5.906250, -5.906250 )
aTempConvex[4] = Vector( -5.906250, 5.906250, -5.906250 )
aTempConvex[5] = Vector( 5.906250, 5.906250, 5.906250 )
aTempConvex[6] = Vector( 5.906250, 5.906250, 5.906250 )
aTempConvex[7] = Vector( 5.906250, 5.906250, -5.906250 )

	table.insert( aMultiConvex, aTempConvex )
	
	xEntity:PhysicsInitMultiConvex( aMultiConvex )
	xEntity:EnableCustomCollisions()

And how can I render the convexes? Like debug collision draw or something

[editline]30th October 2012[/editline]

PhysicsFromMeshConvex() doesnt exist

[editline]30th October 2012[/editline]

Hmm, so model collision is put together from different cubes like brushes. I take it each one of these cubes are a convex hull. What is the vertex arrangement of 1 convex hull?

[editline]30th October 2012[/editline]

Anyone?

Ok so this is pretty much where I’m at.


		local xPhysObj = xEntity:GetPhysicsObject()
		local xMesh = xEntity:GetPhysicsObject():GetMesh()
		
		local aMultiConvex = {}
		local aTempConvex = {}
		local nCount = 0
		
		for k,v in pairs( xMesh ) do
			v.pos = v.pos * fScale
			
			if( nCount < 32 ) then
				table.insert( aTempConvex, v )
				nCount = nCount +1
			else
				table.insert( aMultiConvex, aTempConvex )
				aTempConvex = {}
				nCount = 0
			end
			
			if( nCount == 32 && !aMultiConvex[0] ) then
				table.insert( aMultiConvex, aTempConvex )
				aTempConvex = {}
				nCount = 0
			end			
		end
		
		xEntity:PhysicsInitMultiConvex( aMultiConvex )
		xEntity:EnableCustomCollisions()

I dont know anymore - Garry needs to implement a GetConvexMeshCount() and GetConvexMesh( nIndex ). Then everything would be fine.

gm_queryphys.dll did this but it doesn’t work anymore… Unless someone has a working version and could share it!

Any news on this?