Skip to content

Commit

Permalink
#5310: Fix test.py script
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Oct 2, 2020
1 parent d8b7878 commit bec4d2a
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions install/scripts/test.py
@@ -1,4 +1,5 @@
# Some interface tests
import darkradiant as dr

# Test the Registry interface
value = GlobalRegistry.get('user/paths/appPath')
Expand Down Expand Up @@ -40,7 +41,7 @@
#GlobalEntityClassManager.forEachModelDef(modelDefVisitor)

# Test traversing the scenegraph
class SceneWalker(SceneNodeVisitor) :
class SceneWalker(dr.SceneNodeVisitor) :
def pre(self, node):
print(node.getNodeType())

Expand All @@ -58,7 +59,7 @@ def pre(self, node):
GlobalSceneGraph.root().traverse(walker)

# Test traversing the current selection
class Walker(SelectionVisitor) :
class Walker(dr.SelectionVisitor) :
def visit(self, node):
# Try to "cast" the node to a brush
brush = node.getBrush()
Expand Down Expand Up @@ -104,7 +105,7 @@ def visit(self, node):
print('There is no worldspawn in this map yet')

# Test the entity visitor interface
class TestEntityVisitor(EntityVisitor) :
class TestEntityVisitor(dr.EntityVisitor) :
def visit(self, key, value):
print('Worldspawn has spawnarg: ' + key + ' = ' + value)

Expand Down Expand Up @@ -138,7 +139,7 @@ def visit(self, key, value):
print(path)

# Test FileSystem (VFS)
class TestFileVisitor(FileVisitor) :
class TestFileVisitor(dr.FileVisitor) :
def visit(self, filename):
print('Found file: ' + filename)

Expand All @@ -152,21 +153,22 @@ def visit(self, filename):
print('Current grid size = ' + str(GlobalGrid.getGridSize()))

# Test the ShaderSystem interface
class TestShaderVisitor(ShaderVisitor) :
class TestShaderVisitor(dr.ShaderVisitor) :
def visit(self, shader):
if not shader.isNull():
print('Found shader: ' + shader.getName() + ' defined in ' + shader.getShaderFileName())

shadervisitor = TestShaderVisitor()
GlobalMaterialManager.foreachShader(shadervisitor)
# Disabled code, takes very long in TDM
# shadervisitor = TestShaderVisitor()
# GlobalMaterialManager.foreachShader(shadervisitor)

shader = GlobalMaterialManager.getMaterialForName('bc_rat')

if not shader.isNull():
print('Shader ' + shader.getName() + ' is defined in ' + shader.getShaderFileName())

# Test finding a model
class ModelFinder(SceneNodeVisitor) :
class ModelFinder(dr.SceneNodeVisitor) :
def pre(self, node):
# Try to get a model from this node
model = node.getModel()
Expand Down Expand Up @@ -213,12 +215,12 @@ def pre(self, node):
# modelskin = GlobalModelSkinCache.capture(skin)
# print('Skin found: ' + modelskin.getName())

v = Vector3(6,6,6)
v += Vector3(10,10,10)
v = dr.Vector3(6,6,6)
v += dr.Vector3(10,10,10)
print(v)

# Test patch manipulation
class PatchManipulator(SceneNodeVisitor) :
class PatchManipulator(dr.SceneNodeVisitor) :
def pre(self, node):
# Try to get a patch from this node
patch = node.getPatch()
Expand All @@ -233,7 +235,7 @@ def pre(self, node):
while h < patch.getHeight():
# Push the vertex around a bit
ctrl = patch.ctrlAt(h,w)
ctrl.vertex += Vector3(0,0,10*(h-w))
ctrl.vertex += dr.Vector3(0,0,10*(h-w))
h += 1
w += 1

Expand All @@ -245,7 +247,7 @@ def pre(self, node):
GlobalSceneGraph.root().traverse(walker)

# Test the SelectionSetManager interface
class SelectionSetWalker(SelectionSetVisitor) :
class SelectionSetWalker(dr.SelectionSetVisitor) :
def visit(self, selectionset):
print(selectionset.getName())

Expand Down Expand Up @@ -288,7 +290,7 @@ def visit(self, selectionset):
print('Created group with ID: ' + str(group.getId()))

# Test traversing the current selection
class GroupAdder(SelectionVisitor) :
class GroupAdder(dr.SelectionVisitor) :
def visit(self, node):
group.addNode(node)

Expand All @@ -301,9 +303,13 @@ def visit(self, node):
GlobalSelectionGroupManager.setGroupSelected(group.getId(), 0)

# List nodes in this group
class SelectionGroupWalker(SelectionGroupVisitor) :
class SelectionGroupWalker(dr.SelectionGroupVisitor) :
def visit(self, node):
print('Group Member: ' + node.getNodeType())

gropWalker = SelectionGroupWalker();
group.foreachNode(gropWalker)
group.foreachNode(gropWalker)

camview = GlobalCameraManager.getActiveView()
print(camview.getCameraOrigin())
camview.setCameraOrigin(dr.Vector3(50,0,50))

0 comments on commit bec4d2a

Please sign in to comment.