Skip to content

Commit

Permalink
refactor: trying to make sure that deformations are taken into accoun…
Browse files Browse the repository at this point in the history
…t, does not work yet
  • Loading branch information
ntamas committed Apr 4, 2024
1 parent 2809627 commit cd0e437
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/modules/sbstudio/plugin/model/light_effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,12 +756,15 @@ def _get_bvh_tree_from_mesh(self) -> Optional[BVHTree]:
effect has no associated mesh.
"""
if self.mesh:
b_mesh = bmesh.new()
b_mesh.from_mesh(self.mesh.data)
b_mesh.transform(self.mesh.matrix_world)
tree = BVHTree.FromBMesh(b_mesh)
b_mesh.free()
return tree
depsgraph = bpy.context.evaluated_depsgraph_get()
mesh = self.mesh

obj = depsgraph.objects.get(mesh.name)
if obj:
obj.data.transform(mesh.matrix_world)
tree = BVHTree.FromObject(mesh, depsgraph, deform=True)
obj.data.transform(mesh.matrix_world.inverted())
return tree

def _get_plane_from_mesh(self) -> Optional[Plane]:
"""Returns a plane that is an infinite expansion of the first face of the
Expand Down

0 comments on commit cd0e437

Please sign in to comment.