+ if obj.type == 'MESH':
+ dims = obj.data.cv_data.v0
+ else:
+ dims = obj.cv_data.v0
+
+ vs = [None]*9
+ c = Vector((0,0,dims[2]))
+
+ vs[0] = obj.matrix_world @ Vector((-dims[0],0.0,-dims[1]+dims[2]))
+ vs[1] = obj.matrix_world @ Vector((-dims[0],0.0, dims[1]+dims[2]))
+ vs[2] = obj.matrix_world @ Vector(( dims[0],0.0, dims[1]+dims[2]))
+ vs[3] = obj.matrix_world @ Vector(( dims[0],0.0,-dims[1]+dims[2]))
+ vs[4] = obj.matrix_world @ (c+Vector((-1,0,-2)))
+ vs[5] = obj.matrix_world @ (c+Vector((-1,0, 2)))
+ vs[6] = obj.matrix_world @ (c+Vector(( 1,0, 2)))
+ vs[7] = obj.matrix_world @ (c+Vector((-1,0, 0)))
+ vs[8] = obj.matrix_world @ (c+Vector(( 1,0, 0)))
+
+ indices = [(0,1),(1,2),(2,3),(3,0),(4,5),(5,6),(7,8)]
+
+ for l in indices:
+ v0 = vs[l[0]]
+ v1 = vs[l[1]]
+ verts += [(v0[0],v0[1],v0[2])]
+ verts += [(v1[0],v1[1],v1[2])]
+ colours += [(1,1,0,1),(1,1,0,1)]
+
+ sw = (0.4,0.4,0.4,0.2)
+ if obj.cv_data.target != None:
+ drawbline( obj.location, obj.cv_data.target.location, sw,sw )
+
+ elif obj.cv_data.classtype == 'k_classtype_route_node':
+ sw = Vector((0.4,0.4,0.4,0.2))
+ sw2 = Vector((1.5,0.2,0.2,0.0))
+ if obj.cv_data.target != None:
+ drawbpath( obj, obj.cv_data.target, sw, sw )
+ if obj.cv_data.target1 != None:
+ drawbpath( obj, obj.cv_data.target1, sw, sw )
+
+ drawbhandle( obj, 1.0, (0.8,0.8,0.8,1.0) )
+ drawbhandle( obj, -1.0, (0.4,0.4,0.4,1.0) )
+
+ p1 = obj.location+ \
+ obj.matrix_world.to_quaternion() @ Vector((0,0,-6+1.5))
+ drawbline( obj.location, p1, sw,sw2 )
+
+
+ elif obj.cv_data.classtype == 'k_classtype_block':
+ a = obj.data.cv_data.v0
+ b = obj.data.cv_data.v1
+
+ vs = [None]*8
+ vs[0] = obj.matrix_world @ Vector((a[0], a[1], a[2]))
+ vs[1] = obj.matrix_world @ Vector((a[0], b[1], a[2]))
+ vs[2] = obj.matrix_world @ Vector((b[0], b[1], a[2]))
+ vs[3] = obj.matrix_world @ Vector((b[0], a[1], a[2]))
+ vs[4] = obj.matrix_world @ Vector((a[0], a[1], b[2]))
+ vs[5] = obj.matrix_world @ Vector((a[0], b[1], b[2]))
+ vs[6] = obj.matrix_world @ Vector((b[0], b[1], b[2]))
+ vs[7] = obj.matrix_world @ Vector((b[0], a[1], b[2]))
+
+ indices = [(0,1),(1,2),(2,3),(3,0),(4,5),(5,6),(6,7),(7,4),\
+ (0,4),(1,5),(2,6),(3,7)]
+
+ for l in indices:
+ v0 = vs[l[0]]
+ v1 = vs[l[1]]
+ verts += [(v0[0],v0[1],v0[2])]
+ verts += [(v1[0],v1[1],v1[2])]
+ colours += [(1,1,0,1),(1,1,0,1)]
+
+ elif obj.cv_data.classtype == 'k_classtype_capsule':
+ h = obj.data.cv_data.v0[0]
+ r = obj.data.cv_data.v0[1]
+
+ vs = [None]*10
+ vs[0] = obj.matrix_world @ Vector((0.0,0.0, h*0.5 ))
+ vs[1] = obj.matrix_world @ Vector((0.0,0.0,-h*0.5 ))
+ vs[2] = obj.matrix_world @ Vector(( r,0.0, h*0.5-r))
+ vs[3] = obj.matrix_world @ Vector(( -r,0.0, h*0.5-r))
+ vs[4] = obj.matrix_world @ Vector(( r,0.0,-h*0.5+r))
+ vs[5] = obj.matrix_world @ Vector(( -r,0.0,-h*0.5+r))
+ vs[6] = obj.matrix_world @ Vector((0.0, r , h*0.5-r))
+ vs[7] = obj.matrix_world @ Vector((0.0,-r , h*0.5-r))
+ vs[8] = obj.matrix_world @ Vector((0.0, r ,-h*0.5+r))
+ vs[9] = obj.matrix_world @ Vector((0.0,-r ,-h*0.5+r))
+
+ indices = [(0,1),(2,3),(4,5),(6,7),(8,9)]
+
+ for l in indices:
+ v0 = vs[l[0]]
+ v1 = vs[l[1]]
+ verts += [(v0[0],v0[1],v0[2])]
+ verts += [(v1[0],v1[1],v1[2])]
+ colours += [(0.5,1,0,1),(0.5,1,0,1)]
+
+ elif obj.cv_data.classtype == 'k_classtype_spawn':
+ vs = [None]*4
+ vs[0] = obj.matrix_world @ Vector((0,0,0))
+ vs[1] = obj.matrix_world @ Vector((0,2,0))
+ vs[2] = obj.matrix_world @ Vector((0.5,1,0))
+ vs[3] = obj.matrix_world @ Vector((-0.5,1,0))
+ indices = [(0,1),(1,2),(1,3)]
+ for l in indices:
+ v0 = vs[l[0]]
+ v1 = vs[l[1]]
+ verts += [(v0[0],v0[1],v0[2])]
+ verts += [(v1[0],v1[1],v1[2])]
+ colours += [(0,1,1,1),(0,1,1,1)]
+
+ elif obj.cv_data.classtype == 'k_classtype_route':
+ vs = [None]*2
+ vs[0] = obj.location
+ vs[1] = obj.cv_data.target.location
+ indices = [(0,1)]
+ for l in indices:
+ v0 = vs[l[0]]
+ v1 = vs[l[1]]
+ verts += [(v0[0],v0[1],v0[2])]
+ verts += [(v1[0],v1[1],v1[2])]
+ colours += [(0,1,1,1),(0,1,1,1)]
+
+ stack = [None]*64
+ stack_i = [0]*64
+ stack[0] = obj.cv_data.target
+ si = 1
+ loop_complete = False
+
+ while si > 0:
+ if stack_i[si-1] == 2:
+ si -= 1
+ continue
+
+ if si == 0: # Loop failed to complete
+ break
+
+ node = stack[si-1]
+
+ targets = [None,None]
+ targets[0] = node.cv_data.target
+
+ if node.cv_data.classtype == 'k_classtype_route_node':
+ targets[1] = node.cv_data.target1
+
+ nextnode = targets[stack_i[si-1]]
+ stack_i[si-1] += 1
+
+ if nextnode != None: # branch
+ if nextnode == stack[0]: # Loop completed
+ loop_complete = True
+ break
+
+ valid=True
+ for sj in range(si):
+ if stack[sj] == nextnode: # invalidated path
+ valid=False
+ break
+
+ if valid:
+ stack_i[si] = 0
+ stack[si] = nextnode
+ si += 1
+ continue
+
+ if loop_complete:
+ cc = Vector((obj.cv_data.colour[0],\
+ obj.cv_data.colour[1],\
+ obj.cv_data.colour[2],\
+ 1.0))
+
+ for sj in range(si):
+ sk = (sj+1)%si
+
+ if stack[sj].cv_data.classtype == 'k_classtype_gate' and \
+ stack[sk].cv_data.classtype == 'k_classtype_gate':
+ dist = (stack[sj].location-stack[sk].location).magnitude
+ drawsbpath( stack[sj], stack[sk], cc*0.4, cc, dist, dist )
+
+ else:
+ drawbpath( stack[sj], stack[sk], cc, cc )
+
+ course_count += 1
+
+ elif obj.cv_data.classtype == 'k_classtype_car_path':
+ v0 = obj.matrix_world.to_quaternion() @ Vector((0,1,0))
+ c0 = Vector((v0.x*0.5+0.5, v0.y*0.5+0.5, 0.0, 1.0))
+ drawbhandle( obj, 1.0, (0.9,0.9,0.9,1.0) )
+