GeoMipTerrain error

Hello,

I have another problem with GeoMipTerrain and Collision detection.After the game start, collision detection won’t work on my GeoMipTerrain.Here is the error and code parts:

Error:

:grutil(error): GeoMipTerrain: root node unexpectedly mangled 256 vs 257

Code (Code is really similiar: https://discourse.panda3d.org/viewtopic.php?t=4536 , but with a few changes):

Terrain:

        self.terrain = GeoMipTerrain("Otok-1")
        self.terrain.setHeightfield(Filename("data/default.png"))
        self.terrain.getRoot().setSz(400)
        self.terrain.setBlockSize(32)
        self.terrain.setFactor(400)
        self.terrain.setMinLevel(3)
        self.terrain.getRoot().reparentTo(render)
        self.terrain.getRoot().setPos(0, 0, -180)
        self.terrain.generate()
        tex0 = loader.loadTexture("data/default_d.png")
        tex0.setMinfilter(Texture.FTLinearMipmapLinear)
        tex1 = loader.loadTexture("data/grayRock.png")
        tex1.setMinfilter(Texture.FTLinearMipmapLinear)
        tex2 = loader.loadTexture("data/hardDirt.png")
        tex2.setMinfilter(Texture.FTLinearMipmapLinear)
        tex3 = loader.loadTexture("data/bigRockFace.png")
        tex3.setMinfilter(Texture.FTLinearMipmapLinear)
        tex4 = loader.loadTexture("data/shortGrass.png")
        tex4.setMinfilter(Texture.FTLinearMipmapLinear)
        tex5 = loader.loadTexture("data/default_c.png")
        tex5.setMinfilter(Texture.FTLinearMipmapLinear)
        tex6 = loader.loadTexture("data/default_l.png")
        tex6.setMinfilter(Texture.FTLinearMipmapLinear)
        self.terrain.getRoot().setTexture( TextureStage('tex0'),tex0 )
        self.terrain.getRoot().setTexture( TextureStage('tex1'),tex1 )
        self.terrain.getRoot().setTexture( TextureStage('tex2'),tex2 )
        self.terrain.getRoot().setTexture( TextureStage('tex3'),tex3 )
        self.terrain.getRoot().setTexture( TextureStage('tex4'),tex4 )
        self.terrain.getRoot().setTexture( TextureStage('tex5'),tex5 )
        self.terrain.getRoot().setTexture( TextureStage('tex6'),tex6 )
        self.terrain.getRoot().setShader(loader.loadShader('terraintexture.sha'))
        self.islandToRen=self.terrain.getRoot()
        self.islandToRen.reparentTo(render)
        self.islandToRen.setPos(0, 0, -180)

Collision detection:

      	mColl=self.initCollisionSphere(self.islandToRen, False)
	mColl[0].node().setIntoCollideMask( BitMask32.bit( 1 ))
	mColl[0].node().setFromCollideMask( BitMask32.allOff())
	base.cTrav .addCollider(mColl[0], self.collHandEvent)
	self.accept( 'into-' + mColl[1], self.collide)
	self.accept( 'outof-' + mColl[1], self.collide2)

     def initCollisionSphere( self, obj, show=False):
        bounds = obj.getChild(0).getBounds()
	center = bounds.getCenter()
	radius = bounds.getRadius()*0.9
	collSphereStr = 'CollisionHull' +obj.getName()
	cNode=CollisionNode(collSphereStr)
	cNode.addSolid(CollisionSphere(center, radius ) )
	cNodepath=obj.attachNewNode(cNode)
	if show:
            cNodepath.show()
            
	return (cNodepath,collSphereStr )

I’m running this on Windows XP.
sorry for my bad english!
Regards,
Veki

The error means some sub-node of the terrain got removed or added. Are you somewhere changing nodes, flattening stuff or adding things like collision nodes to the terrain?

I don’t know what initCollisionSphere does – if it adds a collision sphere to the island, well, that is totally useless in most cases, imho. The terrain has never a shape that looks like a sphere. Instead, you are better off colliding with geometry. But most of the time, you don’t need to collide with the terrain at all – you can use getElevation instead, in most cases.

Hello,

I’m not sure, but I think that this parts of code are only place where I’m using it.

Yes, it adds collision sphere to the island.I really don’t know why, but I was try to follow this example: http://panda3d.org/manual/index.php/Bitmask_Example

While I’m writing this I saw your reply, about that:
https://discourse.panda3d.org/viewtopic.php?p=25578&sid=fb1de45e03f2c6f1492d4b22a3445764

Thanks for help!
Sorry for my bad english!
Regards,
Veki