Skip to content

Commit f641de7

Browse files
committed
Remove Scalp (fix opaque scalp)
1 parent 8641166 commit f641de7

File tree

7 files changed

+46
-4
lines changed

7 files changed

+46
-4
lines changed

DazStudioPlugin/DzRobloxAction.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,6 +1404,7 @@ void DzRobloxAction::writeConfiguration()
14041404
writer.addMember("Texture Size", m_nRobloxTextureSize);
14051405
writer.addMember("Texture Bake Quality", m_nBlenderTextureBakeQuality);
14061406
writer.addMember("Hidden Surface Removal", m_bHiddenSurfaceRemoval);
1407+
writer.addMember("Remove Scalp Material", m_bRemoveScalp);
14071408

14081409
if (true)
14091410
{
@@ -1504,6 +1505,7 @@ bool DzRobloxAction::readGui(DZ_BRIDGE_NAMESPACE::DzBridgeDialog* BridgeDialog)
15041505
m_bEnableBreastsGone = pRobloxDialog->m_wBreastsGoneCheckbox->isChecked();
15051506
m_bBakeSingleOutfit = pRobloxDialog->m_wBakeSingleOutfitCheckbox->isChecked();
15061507
m_bHiddenSurfaceRemoval = pRobloxDialog->m_wHiddenSurfaceRemovalCheckbox->isChecked();
1508+
m_bRemoveScalp = pRobloxDialog->m_wRemoveScalpMaterialCheckbox->isChecked();
15071509

15081510
// modesty overlay
15091511
QVariant vModestyData = pRobloxDialog->m_wModestyOverlayCombo->itemData(pRobloxDialog->m_wModestyOverlayCombo->currentIndex());

DazStudioPlugin/DzRobloxAction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ class DzRobloxAction : public DZ_BRIDGE_NAMESPACE::DzBridgeAction {
145145
int m_nReplaceEyebrows = 0;
146146
int m_nReplaceEyelashes = 0;
147147
bool m_bHiddenSurfaceRemoval = false;
148+
bool m_bRemoveScalp = false;
148149

149150
friend class DzRobloxUtils;
150151

DazStudioPlugin/DzRobloxDialog.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,20 +160,26 @@ DzRobloxDialog::DzRobloxDialog(QWidget* parent) :
160160
QLabel* wReplacementPartsRowLabel = new QLabel(tr("Replacement Assets"));
161161

162162
// Accessory Export Options
163-
QHBoxLayout* wClothingOptionsLayout = new QHBoxLayout();
163+
QVBoxLayout* wClothingOptionsLayout = new QVBoxLayout();
164164
m_wBakeSingleOutfitCheckbox = new QCheckBox(tr("Merge all clothing together"));
165165
QString sBakeSingleOutfit = tr("Merge all clothing and hair items togother so that they use a single Roblox clothing slot");
166166
m_wBakeSingleOutfitCheckbox->setToolTip(sBakeSingleOutfit);
167167
m_wBakeSingleOutfitCheckbox->setWhatsThis(sBakeSingleOutfit);
168168
m_wBakeSingleOutfitCheckbox->setChecked(false);
169-
m_wHiddenSurfaceRemovalCheckbox = new QCheckBox(tr("Hidden Geometry Removal"));
169+
m_wHiddenSurfaceRemovalCheckbox = new QCheckBox(tr("Remove Hidden Geometry"));
170170
QString sHiddenSurfaceRemoval = tr("Remove unnecessary triangles which are hidden underneath other triangles and visible (Experimental)");
171171
m_wHiddenSurfaceRemovalCheckbox->setToolTip(sHiddenSurfaceRemoval);
172172
m_wHiddenSurfaceRemovalCheckbox->setWhatsThis(sHiddenSurfaceRemoval);
173173
m_wHiddenSurfaceRemovalCheckbox->setChecked(false);
174+
QString sRemoveScalp = tr("Remove scalp geometry from hair assets. May fix opaque scalp issues.");
175+
m_wRemoveScalpMaterialCheckbox = new QCheckBox(tr("Remove Scalp"));
176+
m_wRemoveScalpMaterialCheckbox->setToolTip(sRemoveScalp);
177+
m_wRemoveScalpMaterialCheckbox->setToolTip(sRemoveScalp);
178+
m_wRemoveScalpMaterialCheckbox->setChecked(true);
174179
wClothingOptionsLayout->addWidget(m_wBakeSingleOutfitCheckbox);
175180
wClothingOptionsLayout->addWidget(m_wHiddenSurfaceRemovalCheckbox);
176-
QLabel* wLayeredClothingRowLabel = new QLabel(tr("Layered Clothing"));
181+
wClothingOptionsLayout->addWidget(m_wRemoveScalpMaterialCheckbox);
182+
QLabel* wLayeredClothingRowLabel = new QLabel(tr("Accessories"));
177183

178184
// Add GUI to layout
179185
mainLayout->insertRow(1, "Roblox Output Folder", robloxOutputFolderLayout);

DazStudioPlugin/DzRobloxDialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ protected slots:
129129
QComboBox* m_wEyelashReplacement;
130130

131131
QCheckBox* m_wHiddenSurfaceRemovalCheckbox;
132+
QCheckBox* m_wRemoveScalpMaterialCheckbox;
132133

133134
virtual void refreshAsset() override;
134135

281 Bytes
Binary file not shown.

DazStudioPlugin/real_version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#define VER_MAJOR 2024
55
#define VER_MINOR 1
66
#define VER_REV 3
7-
#define VER_BUILD 255
7+
#define VER_BUILD 256
88

99
#define TOSTRING(x) #x
1010
#define VERSION_STRING TOSTRING(VER_MAJOR) "." TOSTRING(VER_MINOR) "." TOSTRING(VER_REV) "." TOSTRING(VER_BUILD)

PluginData/blender_dtu_to_r15_accessories.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ def _main(argv):
125125
hidden_surface_removal = dtu_dict["Hidden Surface Removal"]
126126
else:
127127
hidden_surface_removal = False
128+
if "Remove Scalp Material" in dtu_dict:
129+
remove_scalp_material = dtu_dict["Remove Scalp Material"]
130+
else:
131+
remove_scalp_material = False
128132

129133
if "Has Animation" in dtu_dict:
130134
bHasAnimation = dtu_dict["Has Animation"]
@@ -279,6 +283,34 @@ def _main(argv):
279283
else:
280284
main_item.name = roblox_asset_name
281285

286+
if remove_scalp_material:
287+
hair_obj_list = []
288+
for obj in bpy.data.objects:
289+
if obj.type == 'MESH' and "StudioPresentationType" in obj:
290+
if "hair" in obj["StudioPresentationType"].lower():
291+
hair_obj_list.append(obj)
292+
for obj in hair_obj_list:
293+
bpy.ops.object.select_all(action='DESELECT')
294+
obj.select_set(True)
295+
bpy.context.view_layer.objects.active = obj
296+
bpy.ops.object.mode_set(mode='EDIT')
297+
bpy.ops.mesh.select_all(action='DESELECT')
298+
bpy.ops.object.mode_set(mode='OBJECT')
299+
for face in obj.data.polygons:
300+
material_name = obj.material_slots[face.material_index].material.name
301+
# fuzzy match scalp and skullcap
302+
# exact match for "Cap"
303+
if ("scalp" in material_name.lower() or
304+
"skullcap" in material_name.lower() or
305+
"Cap" == material_name
306+
):
307+
print("DEBUG: SCALP REMOVER: material_name=" + material_name)
308+
for vert_index in face.vertices:
309+
obj.data.vertices[vert_index].select = True
310+
bpy.ops.object.mode_set(mode='EDIT')
311+
bpy.ops.mesh.delete(type='VERT')
312+
bpy.ops.object.mode_set(mode='OBJECT')
313+
282314
# convert to texture atlas
283315
safe_material_names_list = []
284316
for obj in bpy.data.objects:

0 commit comments

Comments
 (0)