Skip to content

Commit

Permalink
Merge pull request #133 from WolvenKit/collision_rework
Browse files Browse the repository at this point in the history
switch to getting collision collections by name
  • Loading branch information
DoctorPresto authored Apr 17, 2024
2 parents 7e98fd1 + f88d6eb commit ada8ba0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions i_scene_cp77_gltf/exporters/collision_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
from ..main.common import show_message
from .phys_export import export_colliders_to_phys

def get_collider_collections(context, collider_type):
def get_collider_collections(context, collider_name):
collider_collections = []

for collection in context.scene.collection.children:
type = bpy.data.collections[collection.name]["collider_type"]
if type == collider_type:
collider_collections.append(collection)
for collection in bpy.data.collections:
if collider_name in collection.name:
collider_collections.append(collection.name)

if not collider_collections:
print(f"Error: Collider collection not found.")
print(f"Error: Collider collection '{collider_name}' not found.")
return None
else:
return collider_collections

def cp77_collision_export(filepath, collision_type):
context = bpy.context
if collision_type == 'VEHICLE':
collections = get_collider_collections(context, 'VEHICLE')
collider_name = 'collisions.phys'
collections = get_collider_collections(context, collider_name)
export_colliders_to_phys(collections, filepath)
if collision_type == 'ENTITY':
show_message('Exporting of Entity Colliders is not yet supported')
Expand Down
2 changes: 1 addition & 1 deletion i_scene_cp77_gltf/exporters/phys_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def export_colliders_to_phys(collections, filepath):
index = 1
for collection in collections:
# Iterate over objects in the collection
for obj in collection.objects:
for obj in bpy.data.collections[collection].objects:
if 'collisionShape' in obj:
collider_info = {
"HandleId": str(index),
Expand Down

0 comments on commit ada8ba0

Please sign in to comment.