Skip to content

Commit 5fb63cd

Browse files
Merge pull request #12 from mattedicksoncom/dev
Updates
2 parents 28a15df + 775c767 commit 5fb63cd

File tree

2 files changed

+30
-28
lines changed

2 files changed

+30
-28
lines changed

addons/blender_xatlas/__init__.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"author": "mattedickson",
1919
"wiki_url": "https://github.com/mattedicksoncom/blender-xatlas/",
2020
"tracker_url": "https://github.com/mattedicksoncom/blender-xatlas/issues",
21-
"version": (0, 0, 6),
21+
"version": (0, 0, 7),
2222
"blender": (2, 83, 0),
2323
"location": "3D View > Toolbox",
2424
"category": "Object",
@@ -278,7 +278,7 @@ class PG_SharedProperties (PropertyGroup):
278278
description="Don't unwrap the meshes, only, pack them",
279279
default = False
280280
)
281-
281+
282282

283283
# end PropertyGroups---------------------------
284284

@@ -328,7 +328,7 @@ def execute(self, context):
328328
context.view_layer.objects.active = startingActiveObject
329329
bpy.ops.object.mode_set(mode=startingMode)
330330
# bpy.context.selected_objects = startingSelection
331-
331+
332332

333333
return {'FINISHED'}
334334

@@ -362,7 +362,7 @@ def execute(self, context):
362362

363363
#store the names of objects
364364
rename_dict = dict()
365-
365+
366366
#make sure all the objects have ligthmap uvs
367367
for obj in selected_objects:
368368
if obj.type == 'MESH':
@@ -427,13 +427,13 @@ def execute(self, context):
427427
use_mesh_modifiers=True,
428428
use_edges=True,
429429
use_smooth_groups=False,
430-
use_smooth_groups_bitflags=False,
430+
use_smooth_groups_bitflags=False,
431431
use_normals=True,
432432
use_uvs=True,
433433
use_materials=False,
434434
use_triangles=False,
435-
use_nurbs=False,
436-
use_vertex_groups=False,
435+
use_nurbs=False,
436+
use_vertex_groups=False,
437437
use_blen_objects=True,
438438
group_by_object=False,
439439
group_by_material=False,
@@ -490,7 +490,7 @@ def execute(self, context):
490490

491491
#RUN xatlas process
492492
xatlas_process = subprocess.Popen(
493-
xatlas_path + ' ' + arguments_string,
493+
r'"{}"'.format(xatlas_path) + ' ' + arguments_string,
494494
stdin=subprocess.PIPE,
495495
stdout=subprocess.PIPE,
496496
shell=True
@@ -520,17 +520,17 @@ class uvObject:
520520
obName: string = ""
521521
uvArray: List[float] = field(default_factory=list)
522522
faceArray: List[int] = field(default_factory=list)
523-
523+
524524
convertedObjects = []
525525
uvArrayComplete = []
526526

527-
527+
528528
#search through the out put for STARTOBJ
529529
#then start reading the objects
530530
obTest = None
531531
startRead = False
532532
for line in outObj.splitlines():
533-
533+
534534
line_split = line.split()
535535

536536
if not line_split:
@@ -542,14 +542,14 @@ class uvObject:
542542
print("Start reading the objects----------------------------------------")
543543
startRead = True
544544
# obTest = uvObject()
545-
545+
546546
if startRead:
547547
#if it's a new obj
548548
if line_start == 'o':
549549
#if there is already an object append it
550550
if obTest is not None:
551551
convertedObjects.append(obTest)
552-
552+
553553
obTest = uvObject() #create new uv object
554554
obTest.obName = line_split[1]
555555

@@ -575,8 +575,8 @@ class uvObject:
575575
#append the final object
576576
convertedObjects.append(obTest)
577577
# print(convertedObjects)
578-
579-
578+
579+
580580
#apply the output-------------------------------------------------------------
581581
#copy the uvs to the original objects
582582
# objIndex = 0
@@ -601,7 +601,7 @@ class uvObject:
601601

602602
nFaces = len(bm.faces)
603603
#need to ensure lookup table for some reason?
604-
if hasattr(bm.faces, "ensure_lookup_table"):
604+
if hasattr(bm.faces, "ensure_lookup_table"):
605605
bm.faces.ensure_lookup_table()
606606

607607
#loop through the faces
@@ -639,7 +639,7 @@ class uvObject:
639639
currentObject = bpy.context.scene.objects[edgeList['object']]
640640
bm = bmesh.new()
641641
bm.from_mesh(currentObject.data)
642-
if hasattr(bm.edges, "ensure_lookup_table"):
642+
if hasattr(bm.edges, "ensure_lookup_table"):
643643
bm.edges.ensure_lookup_table()
644644

645645
#assume that all the triangulated edges come after the original edges
@@ -663,7 +663,7 @@ class uvObject:
663663
current_object = bpy.context.scene.objects[objectName]
664664
current_object.select_set(True)
665665
context.view_layer.objects.active = current_object
666-
666+
667667
bpy.ops.object.mode_set(mode=startingMode)
668668

669669
print("Finished Xatlas----------------------------------------")
@@ -676,7 +676,7 @@ class uvObject:
676676
class OBJECT_PT_xatlas_panel (Panel):
677677
bl_idname = "OBJECT_PT_xatlas_panel"
678678
bl_label = "Xatlas Tools"
679-
bl_space_type = "VIEW_3D"
679+
bl_space_type = "VIEW_3D"
680680
bl_region_type = "UI"
681681
bl_category = "Xatlas"
682682
bl_context = ""
@@ -696,7 +696,7 @@ def draw(self, context):
696696
class OBJECT_PT_pack_panel (Panel):
697697
bl_idname = "OBJECT_PT_pack_panel"
698698
bl_label = "Pack Options"
699-
bl_space_type = "VIEW_3D"
699+
bl_space_type = "VIEW_3D"
700700
bl_region_type = "UI"
701701
bl_category = "Xatlas"
702702
bl_parent_id = 'OBJECT_PT_xatlas_panel'
@@ -721,7 +721,7 @@ def draw(self, context):
721721
class OBJECT_PT_chart_panel (Panel):
722722
bl_idname = "OBJECT_PT_chart_panel"
723723
bl_label = "Chart Options"
724-
bl_space_type = "VIEW_3D"
724+
bl_space_type = "VIEW_3D"
725725
bl_region_type = "UI"
726726
bl_category = "Xatlas"
727727
bl_parent_id = 'OBJECT_PT_xatlas_panel'
@@ -745,7 +745,7 @@ def draw(self, context):
745745
class OBJECT_PT_run_panel (Panel):
746746
bl_idname = "OBJECT_PT_run_panel"
747747
bl_label = "Run Xatlas"
748-
bl_space_type = "VIEW_3D"
748+
bl_space_type = "VIEW_3D"
749749
bl_region_type = "UI"
750750
bl_category = "Xatlas"
751751
bl_parent_id = 'OBJECT_PT_xatlas_panel'
@@ -794,8 +794,8 @@ def draw(self, context):
794794
row = box.row()
795795
row.label(text="Atlas Layout")
796796
row.prop( scene.shared_properties, 'atlasLayout')
797-
798-
797+
798+
799799
box.operator("object.setup_unwrap", text="Run Xatlas")
800800

801801
row = box.row()
@@ -830,7 +830,7 @@ def register():
830830
bpy.types.Scene.chart_tool = PointerProperty(type=PG_ChartProperties)
831831
bpy.types.Scene.shared_properties = PointerProperty(type=PG_SharedProperties)
832832

833-
833+
834834

835835
#
836836

@@ -843,8 +843,8 @@ def unregister():
843843
del bpy.types.Scene.shared_properties
844844
del bpy.types.Scene.chart_tool
845845
del bpy.types.Scene.pack_tool
846-
847-
846+
847+
848848

849849

850850

xatlas_src/xatlas.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8897,7 +8897,9 @@ namespace xatlas {
88978897
// Compute chart scale
88988898
float scale = 1.0f;
88998899
if (chart->parametricArea != 0.0f) {
8900-
scale = (chart->surfaceArea / chart->parametricArea) * m_texelsPerUnit;
8900+
//scale = (chart->surfaceArea / chart->parametricArea) * m_texelsPerUnit;
8901+
//see https://github.com/jpcy/xatlas/issues/67
8902+
scale = sqrtf(chart->surfaceArea / chart->parametricArea) * m_texelsPerUnit;
89018903
XA_ASSERT(isFinite(scale));
89028904
}
89038905
// Translate, rotate and scale vertices. Compute extents.

0 commit comments

Comments
 (0)