fix visible obj occluded by portals
This commit is contained in:
parent
036b07e2be
commit
7ed9802886
@ -1412,47 +1412,58 @@ class ExportMyFormat(bpy.types.Operator, ExportHelper):
|
|||||||
|
|
||||||
# Find out if we're left or right of portal
|
# Find out if we're left or right of portal
|
||||||
|
|
||||||
|
# Get vertices world coordinates
|
||||||
|
|
||||||
v0 = hitObject.matrix_world * hitObject.data.vertices[0].co
|
v0 = hitObject.matrix_world * hitObject.data.vertices[0].co
|
||||||
|
|
||||||
v1 = hitObject.matrix_world * hitObject.data.vertices[1].co
|
v1 = hitObject.matrix_world * hitObject.data.vertices[1].co
|
||||||
|
|
||||||
|
# Check side :
|
||||||
|
# 'back' : portal in on the right of the cam, cam is on left of portal
|
||||||
|
# 'front' : portal in on the left of the cam, cam is on right of portal
|
||||||
|
|
||||||
side = checkLine(v0.x, v0.y, v1.x, v1.y , camera.location.x, camera.location.y, camera.location.x, camera.location.y )
|
side = checkLine(v0.x, v0.y, v1.x, v1.y , camera.location.x, camera.location.y, camera.location.x, camera.location.y )
|
||||||
|
|
||||||
if side == 'front':
|
if side == 'front':
|
||||||
|
|
||||||
|
# we're on the right of the portal, origin.x must be > hitLocation.x
|
||||||
|
|
||||||
offset = [ 1.001, 0.999, 0.999 ]
|
offset = [ 1.001, 0.999, 0.999 ]
|
||||||
|
|
||||||
else :
|
else :
|
||||||
|
|
||||||
|
# we're on the left of the portal, origin.x must be < hitLocation.x
|
||||||
|
|
||||||
offset = [ 0.999, 1.001, 1.001 ]
|
offset = [ 0.999, 1.001, 1.001 ]
|
||||||
|
|
||||||
|
# Add offset to hitLocation, so that the new ray won't hit the same portal
|
||||||
|
|
||||||
origin = Vector( ( hitLocation.x * offset[0], hitLocation.y * offset[1], hitLocation.z * offset[2] ) )
|
origin = Vector( ( hitLocation.x * offset[0], hitLocation.y * offset[1], hitLocation.z * offset[2] ) )
|
||||||
|
|
||||||
print(hitObject.name + " is a portal at " + str( hitLocation ) + " N : " + str(normal) + " - " + side + "Or : " + str(origin) )
|
# ~ print(hitObject.name + " is a portal at " + str( hitLocation ) + " N : " + str(normal) + " - " + side + "Or : " + str(origin) )
|
||||||
|
|
||||||
result, hitLocationPort, normal, index, hitObjectPort, matrix = scene.ray_cast( origin , dirToTarget )
|
result, hitLocationPort, normal, index, hitObjectPort, matrix = scene.ray_cast( origin , dirToTarget )
|
||||||
|
|
||||||
print( camera.name + " : recasting from " + str( origin ) + " to " + target.name )
|
# ~ print( camera.name + " : recasting from " + str( origin ) + " to " + target.name )
|
||||||
|
|
||||||
if hitObjectPort is not None:
|
if hitObjectPort is not None:
|
||||||
|
|
||||||
if hitObjectPort in rayTargets:
|
if hitObjectPort in rayTargets:
|
||||||
|
|
||||||
print(hitObjectPort.name)
|
# ~ print(hitObjectPort.name)
|
||||||
|
|
||||||
visibleTarget.append(target)
|
visibleTarget.append(target)
|
||||||
|
|
||||||
|
# If hitObject is not a portal, just add it
|
||||||
|
|
||||||
elif hitObject in rayTargets:
|
elif hitObject in rayTargets:
|
||||||
|
|
||||||
visibleTarget.append(target)
|
visibleTarget.append(target)
|
||||||
|
|
||||||
|
|
||||||
print("\n")
|
|
||||||
|
|
||||||
if bpy.data.objects[ actorPtr ] not in visibleTarget:
|
if bpy.data.objects[ actorPtr ] not in visibleTarget:
|
||||||
|
|
||||||
visibleTarget.append( bpy.data.objects[ actorPtr ] )
|
visibleTarget.append( bpy.data.objects[ actorPtr ] )
|
||||||
|
|
||||||
|
|
||||||
prefix = CleanName(camera.name)
|
prefix = CleanName(camera.name)
|
||||||
|
|
||||||
# Include Tim data
|
# Include Tim data
|
||||||
|
Loading…
Reference in New Issue
Block a user