有两层时如何解决Qt3D窗口的实体闪烁问题?

时间:2018-10-22 08:26:52

标签: python-3.x pyside2 qt3d

我有一个Qt3DWindow和两个QLayer-。当我对第二个实体进行一些更改(转换,添加(子)实体)时,entity_1中的(子)实体会不时闪烁。有谁知道这种行为的原因是什么?

class Window(Qt3DExtras.Qt3DWindow):
    def __init__(self):
        super().__init__()
        self.root_entity = Qt3DCore.QEntity()
        self.entity_1 = Qt3DCore.QEntity(self.root_entity)
        self.entity_2 = Qt3DCore.QEntity(self.root_entity)
        self.setRootEntity(self.root_entity)

        # some other code

        self.surselector = Qt3DRender.QRenderSurfaceSelector()
        self.surselector.setSurface(self)
        self.viewport = Qt3DRender.QViewport(self.surselector)
        self.setActiveFrameGraph(self.surselector)

        # 1
        self.layerfilter_1 = Qt3DRender.QLayerFilter(self.viewport)
        self.layer_1 = Qt3DRender.QLayer(self.entity_1)
        self.entity_1.addComponent(self.layer_1)
        self.layer_1.setRecursive(True)
        self.layerfilter_1.addLayer(self.layer_1)
        self.cameraSelector_1 = Qt3DRender.QCameraSelector(self.layerfilter_1)
        self.clearBuffers_1 = Qt3DRender.QClearBuffers(self.cameraSelector_1)
        self.cameraSelector_1.setCamera(self.camera())
        self.clearBuffers_1.setBuffers(Qt3DRender.QClearBuffers.AllBuffers)

        # 2
        self.layerfilter_2 = Qt3DRender.QLayerFilter(self.viewport)
        self.layer_2 = Qt3DRender.QLayer(self.entity_2)
        self.entity_2.addComponent(self.layer_2)
        self.layer_2.setRecursive(True)
        self.layerfilter_2.addLayer(self.layer_2)
        self.cameraSelector_2 = Qt3DRender.QCameraSelector(self.layerfilter_2)
        self.clearBuffers_2 = Qt3DRender.QClearBuffers(self.cameraSelector_2)
        self.cameraSelector_2.setCamera(self.camera())
        # This line below makes (2) different from (1)
        self.clearBuffers_2.setBuffers(Qt3DRender.QClearBuffers.DepthBuffer)

0 个答案:

没有答案