ray_cast ok

This commit is contained in:
ABelliqueux 2021-03-25 10:50:54 +01:00
parent 386e560779
commit 32ee286796

View File

@ -474,9 +474,11 @@ class ExportMyFormat(bpy.types.Operator, ExportHelper):
# Add objects of type MESH with a Rigidbody or StaticBody flag set to a list # Add objects of type MESH with a Rigidbody or StaticBody flag set to a list
if bpy.data.objects[o].type == 'MESH' and ( bpy.data.objects[o].data.get('isRigidBody') or bpy.data.objects[o].data.get('isStaticBody') ) : if bpy.data.objects[o].type == 'MESH':
rayTargets.append(bpy.data.objects[o]) if bpy.data.objects[o].data.get('isRigidBody') or bpy.data.objects[o].data.get('isStaticBody') :
rayTargets.append(bpy.data.objects[o])
# Set object of type CAMERA with isDefault flag as default camera # Set object of type CAMERA with isDefault flag as default camera
@ -1156,6 +1158,8 @@ class ExportMyFormat(bpy.types.Operator, ExportHelper):
# Cast a ray from camera to each Rigid/Static body to determine visibility # Cast a ray from camera to each Rigid/Static body to determine visibility
# Get current scene
scene = bpy.context.scene scene = bpy.context.scene
# List of target found visible # List of target found visible
@ -1164,7 +1168,7 @@ class ExportMyFormat(bpy.types.Operator, ExportHelper):
for target in rayTargets: for target in rayTargets:
print(target) # ~ print(target)
# Chech object is in view frame # Chech object is in view frame
@ -1172,6 +1176,8 @@ class ExportMyFormat(bpy.types.Operator, ExportHelper):
if inViewFrame: if inViewFrame:
# ~ print(camera.name + ":" + target.name + "\n")
# Get normalized direction vector between camera and object # Get normalized direction vector between camera and object
dirToTarget = target.location - camera.location dirToTarget = target.location - camera.location
@ -1186,9 +1192,15 @@ class ExportMyFormat(bpy.types.Operator, ExportHelper):
# If hitObject is the same as target, nothing is obstructing it's visibility # If hitObject is the same as target, nothing is obstructing it's visibility
# ~ print(target.name + "-" + hitObject.name)
if hitObject is not None: if hitObject is not None:
if hitObject.name == target.name: # ~ if hitObject.data.get('isStaticBody') or hitObject.data.get('isRigidBody') :
if hitObject in rayTargets:
print(camera.name + ":" + hitObject.name + " - " + target.name )
visibleTarget.append(target) visibleTarget.append(target)