Skip to content

Commit b184c54

Browse files
committed
Added support for multiple $models, for static prop lightmapping
1 parent f98c447 commit b184c54

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

addon/props/model_props.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ class SOURCEOPS_ModelProps(bpy.types.PropertyGroup):
4949
type=bpy.types.Collection,
5050
)
5151

52+
separatemodel: bpy.props.PointerProperty(
53+
name='$Models',
54+
description='Visible meshes, each mesh becomes $model in the QC; for lightmapping',
55+
type=bpy.types.Collection,
56+
)
57+
5258
stacking: bpy.props.PointerProperty(
5359
name='Stacking',
5460
description='Visible meshes drawn in the specified order',

addon/types/model_export/model.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def __init__(self, game, model):
4747
self.collision = model.collision
4848
self.bodygroups = model.bodygroups
4949
self.stacking = model.stacking
50+
self.separatemodel = model.separatemodel
5051

5152
self.surface = model.surface
5253
self.glass = model.glass
@@ -99,6 +100,14 @@ def export_meshes(self):
99100
path = self.get_body_path(collection)
100101
self.export_mesh(self.armature, objects, path)
101102

103+
if self.separatemodel:
104+
for separatemodel in self.separatemodel.children:
105+
for collection in separatemodel.children:
106+
objects = self.get_all_objects(collection)
107+
path = self.get_body_path(collection)
108+
self.export_mesh(self.armature, objects, path)
109+
110+
102111
def export_anim(self, armature, action, path):
103112
self.export_smd(armature, [], action, path)
104113

@@ -248,6 +257,15 @@ def generate_qc(self):
248257
name = common.clean_filename(collection.name)
249258
qc.write(f'$model "{name}" "{name}.{self.mesh_type}"')
250259
qc.write('\n')
260+
261+
if self.separatemodel:
262+
for separatemodel in self.separatemodel.children:
263+
qc.write('\n')
264+
bodygroup_name = common.clean_filename(separatemodel.name)
265+
for collection in separatemodel.children:
266+
name = common.clean_filename(collection.name)
267+
qc.write(f'$model "{bodygroup_name}" "{name}.{self.mesh_type}"')
268+
qc.write('\n')
251269

252270
if not self.sequence_items:
253271
qc.write('\n')

addon/ui/panels.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def draw(self, context):
7373
col.prop(model, 'collision')
7474
col.prop(model, 'bodygroups')
7575
col.prop(model, 'stacking')
76+
col.prop(model, 'separatemodel')
7677

7778
elif model and sourceops.panel == 'MODEL_OPTIONS':
7879
box = layout.box()

0 commit comments

Comments
 (0)