Skip to content

Commit

Permalink
feat(light): Sets light radius per default to 0.25 to be backwards co…
Browse files Browse the repository at this point in the history
…mpatible
  • Loading branch information
cornerfarmer committed Aug 22, 2023
1 parent 09bc89d commit 0dcb7df
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions blenderproc/python/types/LightUtility.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self, light_type: str = "POINT", name: str = "light", blender_obj:
light_obj = bpy.data.objects.new(name=name, object_data=light_data)
bpy.context.collection.objects.link(light_obj)
super().__init__(light_obj)
self.set_radius(0.25)
else:
super().__init__(blender_obj)

Expand All @@ -46,6 +47,16 @@ def set_energy(self, energy: float, frame: Optional[int] = None):
self.blender_obj.data.energy = energy
Utility.insert_keyframe(self.blender_obj.data, "energy", frame)

def set_radius(self, radius: float, frame: Optional[int] = None):
""" Sets the radius / shadow_soft_size of the light.
:param radius: Light size for ray shadow sampling (Raytraced shadows).
:param frame: The frame number which the value should be set to. If None is given, the current
frame number is used.
"""
self.blender_obj.data.shadow_soft_size = radius
Utility.insert_keyframe(self.blender_obj.data, "shadow_soft_size", frame)

def set_color(self, color: Union[list, Color], frame: Optional[int] = None):
""" Sets the color of the light.
Expand Down Expand Up @@ -191,6 +202,16 @@ def get_energy(self, frame: Optional[int] = None) -> float:
with KeyFrame(frame):
return self.blender_obj.data.energy

def get_radius(self, frame: Optional[int] = None) -> float:
""" Returns the radius / shadow_soft_size of the light.
:param frame: The frame number which the value should be set to. If None is given, the current
frame number is used.
:return: The radius at the specified frame.
"""
with KeyFrame(frame):
return self.blender_obj.data.shadow_soft_size

def get_color(self, frame: Optional[int] = None) -> Color:
""" Returns the RGB color of the light.
Expand Down

0 comments on commit 0dcb7df

Please sign in to comment.