Skip to content

Commit

Permalink
Fix arrows
Browse files Browse the repository at this point in the history
Reduce debugging output

Reduce z-fighting in imposter shaders
  • Loading branch information
sjackso committed May 30, 2019
1 parent ff87418 commit 56fd490
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/athena/bildparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def addCylinder( self, tokens ):
self.cylinders.append( Cylinder( self.current_color, *(float(x)*(self.scale_factor) for x in tokens) ) )

def addArrow( self, tokens ):
self.arrows.append( Arrow( self.current_color, *(float(x) for x in tokens) ) )
self.arrows.append( Arrow( self.current_color, *(float(x)*(self.scale_factor) for x in tokens) ) )

def debugSummary( self ):
pattern = 'parsed BILD: {0} unique colors, {1} spheres, {2} cylinders, {3} arrows' +\
Expand Down
13 changes: 11 additions & 2 deletions src/athena/decorations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@

class SphereDecorations(Qt3DCore.QEntity):

def __init__(self, parent, spherelist):
def __init__(self, parent, bildfile):
super().__init__(parent)
spherelist = bildfile.spheres
num_spheres = len(spherelist)

if num_spheres == 0: return

total_vertices = num_spheres
vertex_basetype = geom.basetypes.Float
if( total_vertices < 30000 ):
Expand All @@ -25,6 +28,7 @@ def __init__(self, parent, spherelist):
vertex_nparr = np.zeros([total_vertices,7],dtype=geom.basetype_numpy_codes[vertex_basetype])

for idx, (color, x, y, z, r) in enumerate(spherelist):
if color is None: color = QColor('white')
vertex_nparr[idx,:] = x, y, z, r, color.redF(), color.greenF(), color.blueF()

self.geometry = Qt3DRender.QGeometry(self)
Expand Down Expand Up @@ -54,10 +58,14 @@ def __init__(self, parent, spherelist):

class CylinderDecorations(Qt3DCore.QEntity):

def __init__(self, parent, cylinderlist):
def __init__(self, parent, bildfile):
super().__init__(parent)
# Draw the arrow bodies as cylinders too
cylinderlist = bildfile.cylinders + [ Cylinder(*x[:8]) for x in bildfile.arrows]
num_cylinders = len(cylinderlist)

if num_cylinders == 0: return

total_vertices = 2 * num_cylinders
vertex_basetype = geom.basetypes.Float
if( total_vertices < 30000 ):
Expand All @@ -67,6 +75,7 @@ def __init__(self, parent, cylinderlist):

vertex_nparr = np.zeros([total_vertices,7],dtype=geom.basetype_numpy_codes[vertex_basetype])
for idx, (color, x1, y1, z1, x2, y2, z2, r) in enumerate(cylinderlist):
if color is None: color = QColor('white')
vertex_nparr[2*idx,:] = x1, y1, z1, r, color.redF(), color.greenF(), color.blueF()
vertex_nparr[2*idx+1,:] = x2, y2, z2, r, color.redF(), color.greenF(), color.blueF()

Expand Down
3 changes: 1 addition & 2 deletions src/athena/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ def parseLCBBToolOutput( output ):
iter_out = iter(output.split('\n'))
for line in iter_out:
if line.strip().startswith('2.7.'):
print(line)
line27a = next(iter_out)
line27b = next(iter_out)
result['edge_length'] = float( line27a.split(':')[1].strip() )
Expand Down Expand Up @@ -372,7 +371,7 @@ def selectOutput( self, selection_idx ):
if selection_idx == -1: return
(bildfile, scale_factor) = self.outputSelectBox.itemData(selection_idx)
decorations = bildparser.parseBildFile( bildfile, scale_factor )
print(decorations.debugSummary())
#print(decorations.debugSummary())
self.geomView.newDecorations( decorations )

def updateStatus( self, msg ):
Expand Down
27 changes: 14 additions & 13 deletions src/athena/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,16 +332,17 @@ def __init__(self):
self.transPassFilter.setValue('transp')
self.qfilt2.addMatch(self.transPassFilter)

fg = self.activeFrameGraph()
def frameGraphLeaf(node, prefix=' '):
print(prefix, node, node.objectName())
children = node.children()
for c in children:
frameGraphLeaf(c, prefix+'-')

frameGraphLeaf(fg)
# Framegraph display and testing code
#fg = self.activeFrameGraph()
#def frameGraphLeaf(node, prefix=' '):
#print(prefix, node, node.objectName())
#children = node.children()
#for c in children:
#frameGraphLeaf(c, prefix+'-')

#frameGraphLeaf(fg)
self.setActiveFrameGraph(self.surfaceSelector)
frameGraphLeaf(self.activeFrameGraph())
#frameGraphLeaf(self.activeFrameGraph())

self.setBackgroundColor( QColor(63,63,63) )
self.lightOrientation = int(0) # Internal integer controlling light.position attribute
Expand Down Expand Up @@ -400,10 +401,10 @@ def frameGraphLeaf(node, prefix=' '):
backgroundColorChanged = Signal( QColor )

def backgroundColor( self ):
return self.defaultFrameGraph().clearColor()
return self.clearBuffers.clearColor()

def setBackgroundColor( self, color ):
self.defaultFrameGraph().setClearColor( color )
self.clearBuffers.setClearColor( color )
self.backgroundColorChanged.emit(color)

faceRenderingEnabledChanged = Signal( bool )
Expand Down Expand Up @@ -481,9 +482,9 @@ def newDecorations(self, bild_results):
self.clearDecorations()

if( bild_results.spheres ):
self.spheres = decorations.SphereDecorations(self.decorationEntity, bild_results.spheres)
self.spheres = decorations.SphereDecorations(self.decorationEntity, bild_results)
self.spheres.addComponent( self.sphere_material )

if( bild_results.cylinders ):
self.cylinders = decorations.CylinderDecorations(self.decorationEntity, bild_results.cylinders)
self.cylinders = decorations.CylinderDecorations(self.decorationEntity, bild_results)
self.cylinders.addComponent( self.cylinder_material )
4 changes: 3 additions & 1 deletion src/qml/imposter.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ Material {
RenderPass {
// populated with a shader within geomview.py, since qml cannot usefully work with
// relative file paths for shader loading
renderStates: [ MultiSampleAntiAliasing{} ]
renderStates: [ CullFace{ mode: CullFace.NoCulling },
DepthTest{ depthFunction: DepthTest.LessOrEqual },
MultiSampleAntiAliasing{} ]
} ]
}
]
Expand Down

0 comments on commit 56fd490

Please sign in to comment.