Collision problem.

Hi all!

Has anyone had a problem like a picture below?

I attached a collision sphere to an avatar names “Girl”.
And export a model names “Box”,create from a box in 3DsMax7, and export it as “pos” type.

When I run an application and control the girl walking through the box.
The collision sphere hasn’t touch the box yet,
but the program detect as they are collide already. (as a picture above)

Any idea? :cry:

This is only a vague recollection… I seem to recall that there might be a small error in the handling of scale factors in the collision system.

Is it possible that there is a scale factor applied to the girl or the box? Perhaps the sphere is being rendered smaller than it actually is, or something like that.

Yes,it is.
I set the girl’s scale to 0.0012.
it is very small ,isn’t it. :blush:

Thank you for your advise!
I will fix it.

is there any work going on fixing scaling problems in the collisions system?

I believe that the collision system works for uniform scales. The thing it doesn’t handle well is non-uniform scales. The problem is that under a non-uniform scale, a sphere is no longer a sphere, and requires a more complex, more expensive intersection test.

I have little interest in supporting this more complex, more expensive intersection test. Spheres are enough work. So that’s why non-uniform scales are not supported by the collision system, and we have no plans for supporting them.

Usually it is a problem when there is a non-uniform scale on the object the sphere is colliding into, and more often then not when there is a non-uniform scale on a wall, it was used to construct the wall and has no other purpose. In this case, it is easy to do:

wall.flattenLight()

which applies the scale onto the vertices and removes it. This is generally a good thing to do anyway, since it improves rendering performance. Otherwise Panda has to apply that scale to the wall every frame in real time.

David

thank you for clearing uniform scaling. So we can setScale(3) or setScale(.0001) and it would still work? For some reason i think we had problems with that too during pyweek AFF: Iron Angels game(https://discourse.panda3d.org/viewtopic.php?t=3087&highlight=pyweek). But we had problems with every thing then…

For scale larger than 1, the result is still better than if it’s smaller than 1.

from pandac.PandaModules import *
import direct.directbase.DirectStart
from direct.interval.IntervalGlobal import *

def pingpongIval(ival, wait=0):
    return Sequence(
                ival,
                Wait(wait),
                Func(ival.start, 0, ival.getDuration(),-1),
                Wait(ival.getDuration())
                )

base.setBackgroundColor(0,0,0)
base.cTrav = CollisionTraverser()
base.cTrav.showCollisions(render)
GRAVhandler = CollisionHandlerGravity()

for b in range(6):
    box=loader.loadModel('misc/rgbCube')
    box.reparentTo(render)
    box.setPos(0,-b*.8,-b*.5)
    box.setP(10)
    box.setCollideMask(BitMask32.bit(0))

smileyIvalDum = render.attachNewNode('')
smiley = smileyIvalDum.attachNewNode('')
#############################################################
scale=.07  # <------  CHANGE THE SCALE
#############################################################
smiley.setScale(scale)
arrow=loader.loadModel('misc/Dirlight')
arrow.reparentTo(smiley)
arrow.setP(-90)
arrow.setZ(2.5/scale)
arrow.setScale(Vec3(.5,.3,.0001)/scale)
smileyCN=smiley.attachCollisionRay('smiley',0,0,2./scale,0,0,-1,BitMask32.bit(0),BitMask32.allOff())
smileyCN.show()
pingpongIval( smileyIvalDum.posInterval(7,Point3(0,-4,20),Point3(0,0,20)) ).loop()

GRAVhandler.addCollider(smileyCN,smiley)
base.cTrav.addCollider(smileyCN,GRAVhandler)

camera.setPos(10,-10,5)
camera.lookAt(0,-2.5,-1)
mat4=Mat4(camera.getMat())
mat4.invertInPlace()
base.mouseInterfaceNode.setMat(mat4)

run()