Skip to content

Commit

Permalink
Fix an error
Browse files Browse the repository at this point in the history
  • Loading branch information
petak5 committed May 16, 2022
1 parent d207418 commit 597db79
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions terrain_eroder/operators/erosion_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class ErosionOperator(bpy.types.Operator):

__timer: bpy.types.Timer = None

__DEBUG: bool = False


@classmethod
def poll(self, context: bpy.types.Context):
Expand Down Expand Up @@ -110,10 +112,11 @@ def start_erosion(self, context: bpy.types.Context):
self.my_bmesh.verts.ensure_lookup_table()

""" Debug """
temp_sum = 0
for i in range(len(self.my_bmesh.verts)):
temp_sum += self.my_bmesh.verts[i].co.z
print(f"Before = {temp_sum}")
if self.__DEBUG:
temp_sum = 0
for i in range(len(self.my_bmesh.verts)):
temp_sum += self.my_bmesh.verts[i].co.z
print(f"Before = {temp_sum}")
""" Debug end """

settings = None
Expand Down Expand Up @@ -143,7 +146,7 @@ def start_erosion(self, context: bpy.types.Context):
# vg_idx = obj.vertex_groups.active_index
# indices: list[int] = [ v.index for v in obj.data.vertices if vg_idx in [ vg.group for vg in v.groups ] ]
indices: list[int] = []
for v in obj.data.vertices:
for v in self.active_object.data.vertices:
if len(v.groups) > 0:
indices.append(v.index)
settings.selected_vertex_indices = indices
Expand Down Expand Up @@ -174,10 +177,11 @@ def start_erosion(self, context: bpy.types.Context):
# Convert Mesh back to Object
def finish_erosion(self, context: bpy.types.Context):
""" Debug """
temp_sum = 0
for i in range(len(self.my_bmesh.verts)):
temp_sum += self.my_bmesh.verts[i].co.z
print(f"After = {temp_sum}")
if self.__DEBUG:
temp_sum = 0
for i in range(len(self.my_bmesh.verts)):
temp_sum += self.my_bmesh.verts[i].co.z
print(f"After = {temp_sum}")
""" Debug end """

active_mesh = self.active_object.data
Expand Down

0 comments on commit 597db79

Please sign in to comment.