Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

Commit

Permalink
Bugs chasing in model creation
Browse files Browse the repository at this point in the history
Thanks to @regulus_Fen for pointing them out while trying to create his own model.
  • Loading branch information
TetoTheSquirrelFox committed Sep 7, 2020
1 parent 6e5979f commit 09f0349
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
25 changes: 17 additions & 8 deletions jointscreator.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,18 @@ def save_joints_base_file():
# --------------------------------------------------
current_joint_central_point = None

def create_current_joint_central_point():
global current_joint_central_point
mesh = bpy.data.meshes.new('Basic_Sphere')
current_joint_central_point = bpy.data.objects.new("Joint center", mesh)
bm = bmesh.new()
bmesh.ops.create_uvsphere(bm, u_segments=4, v_segments=4, diameter=0.004)
bm.to_mesh(mesh)
bm.free()
file_ops.link_to_collection(current_joint_central_point)
current_joint_central_point.hide_select = True


def show_central_point(hist):
global current_joints_base_file
global current_joint_central_point
Expand All @@ -240,14 +252,7 @@ def show_central_point(hist):
# Now we have all vertices, we compute the average center
central_point = algorithms.average_center(vertices)
if current_joint_central_point == None:
mesh = bpy.data.meshes.new('Basic_Sphere')
current_joint_central_point = bpy.data.objects.new("Joint center", mesh)
bm = bmesh.new()
bmesh.ops.create_uvsphere(bm, u_segments=4, v_segments=4, diameter=0.004)
bm.to_mesh(mesh)
bm.free()
file_ops.link_to_collection(current_joint_central_point)
current_joint_central_point.hide_select = True
create_current_joint_central_point()
current_joint_central_point.location = (central_point.x, central_point.y, central_point.z)

# --------------------------------------------------
Expand Down Expand Up @@ -346,6 +351,8 @@ def show_offset_point(hist):
if current_offset_point == None:
create_offset_point()
co = file[hist.name]
if current_joint_central_point == None: # It happens.
create_current_joint_central_point()
vect = current_joint_central_point.location
current_offset_point.location = (
vect.x + co[0],
Expand Down Expand Up @@ -407,6 +414,8 @@ def set_offset_point():
for key, item in current_joints_offset_file.items():
file = item
# Now we calculate de relative location of the offset
if current_joint_central_point == None: # Security.
create_current_joint_central_point()
center_point = current_joint_central_point.location
offset_point = current_offset_point.location
file[hist.name] = [
Expand Down
4 changes: 2 additions & 2 deletions measurescreator.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def get_two_points(direction=0):
two_points_index += 1
if two_points_index >= len(measures_parts_points):
two_points_index = 0
if two_points_index >= measures_parts_points: # It happens
if two_points_index >= len(measures_parts_points): # It happens
two_points_index = len(measures_parts_points)-1
measure_name = measures_parts_points[two_points_index]
# Now we seek and keep the values in the MeshHandling.
Expand Down Expand Up @@ -428,7 +428,7 @@ def get_girth(direction=0):
girth_index += 1
if girth_index >= len(measures_parts_girths):
girth_index = 0
if girth_index >= measures_parts_girths: # It happens
if girth_index >= len(measures_parts_girths): # It happens
girth_index = len(measures_parts_girths)-1
measure_name = measures_parts_girths[girth_index]
# Now we seek and keep the values in the MeshHandling.
Expand Down

1 comment on commit 09f0349

@animate1978
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just found this code change... was wondering, since it is in the joints creation area, that if this would help solve the issue of skeletons being half scale...

Issue can be found here -
#318

Please sign in to comment.