problem with latest builds

Hi there,

Not really sure where to post this, as I don’t feel like I know enough to file a bug report. I looked at the bug reports, and couldn’t really tell if it has been reported yet. This has to do with the way 2D/OrthographicLens is handled in Panda3d. I am trying to plot stuff according to pixel location. It is, of course, possible I am trying to do something I shouldn’t really be able to do, and just got away with it until now. :slight_smile: At any rate, I have noticed a difference in the way my code is handled in the latest developers SDK and the latest stable SDK (Windows). If I run the code below on the stable SDK, I get 9 evenly spaced smileys on the screen, but if I run the code on the latest SDK (503), I just get one smiley in the center. This is also true in other recent SDK’s, at least as far back as 496.

from __future__ import division
from direct.showbase.ShowBase import ShowBase
from direct.showbase.DirectObject import DirectObject
from panda3d.core import Point3
from panda3d.core import OrthographicLens
from panda3d.core import WindowProperties
import sys

class World(DirectObject):
    def __init__(self):
        DirectObject.__init__(self)
        self.base = ShowBase()
        resolution = (1024, 768)
        wp = WindowProperties()
        wp.setSize(int(resolution[0]), int(resolution[1]))
        wp.setOrigin(0, 0)
        self.base.win.requestProperties(wp)
        # depth completely doesn't matter for this, since just 2d, and no layers
        self.depth = 0
        self.base.setBackgroundColor(115/255, 115/255, 115/255)
        # set up a 2d camera
        camera = self.base.camList[0]
        lens = OrthographicLens()
        lens.setFilmSize(int(resolution[0]), int(resolution[1]))
        lens.setNearFar(-100, 100)
        camera.node().setLens(lens)
        camera.reparentTo(self.base.render)
        self.accept("escape", sys.exit)
        # spread out some positions
        self.positions = [(-200, 0, -200),
                          (0, 0, -200),
                          (200, 0, -200),
                          (-200, 0, 0),
                          (0, 0, 0),
                          (200, 0, 0),
                          (-200, 0, 200),
                          (0, 0, 200),
                          (200, 0, 200)]
        self.all_smiles()

    def next_smile(self, index):
        pos = self.positions[index]
        smiley = loader.loadModel('smiley.egg')
        smiley.setPos(Point3(pos))
        smiley.setScale(20)
        smiley.reparentTo(self.base.render)
        print smiley.getPos()

    def all_smiles(self):
        for ind in range(9):
            self.next_smile(ind)

if __name__ == "__main__":
    W = World()
    W.base.run()

FYI, your code works fine for me in 1.8.1 on Mac (9 smilies). I didn’t try any other version. I don’t know whether you’re doing anything unsupported, but I’d guess you’ve found a real bug.

Yes, I can reproduce: I get only one smiley.

It appears to be a culling issue, since when I disable culling like this:

        smiley.node().setBounds(OmniBoundingVolume())
        smiley.node().setFinal(True)

it does show all nine. Odd.

I’ll look into it.

OK, got it. The issue is that the bounding volume of the lens was not being computed correctly, which caused the other spheres to be culled away.

I tracked the problem down to the matrix invert function. When a matrix has a small determinant, as is the case for the projection matrix of your lens (which has a large film size), the matrix is considered singular (non-invertible). Now, we build with the Eigen library for linear math nowadays, which uses a different threshold in determining how small the determinant is allowed to be.

The second part of this issue was that Panda failed to report a warning message for the failed matrix invert operation, and instead silently assigned it to the identity matrix, which made it hard to spot the issue.

I’ve just checked in a fix by changing the determinant threshold to the same one that we use without Eigen (1e-12, as opposed to Eigen’s default of 1e-5). (I also fixed the warning message).

The code now shows all 9 spheres, with my fixes applied. Thanks for reporting the bug! I’m glad that we were able to catch this bug before release.

Yay, thanks. Do you have an ETA for a build with a fix?

thanks,
Maria

No, sorry. The buildbots need maintenance before they can function again, and I’ll be out of the country for the coming week. If you want the changes now, you would have to grab the source and build it yourself:
github.com/panda3d/panda3d

Alternatively, to work around the issue, you would have to lower the film size of your lens, or disable culling by calling the following:

camera.node().setCullBounds(OmniBoundingVolume())