Skip to content

Commit

Permalink
python: Retain handle to renderer in scene class
Browse files Browse the repository at this point in the history
Few random tweaks I had knocking around in my staging area included as
well.
  • Loading branch information
vkoskiv committed Jan 4, 2024
1 parent e55036d commit 284c616
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions bindings/c_ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,9 @@ def add(self, material):
_lib.material_set_add(self.scene_ptr, self.cr_idx, capsule)

class scene:
def __init__(self, scene_ptr):
self.cr_ptr = scene_ptr
def __init__(self, cr_renderer):
self.cr_renderer = cr_renderer
self.cr_ptr = _lib.renderer_scene_get(self.cr_renderer)
self.meshes = {}
self.cameras = {}
def close(self):
Expand Down Expand Up @@ -389,6 +390,7 @@ def __init__(self, path = None):
self.obj_ptr = _lib.new_renderer()
self.prefs = _pref(self.obj_ptr)
self.callbacks = _callbacks(self.obj_ptr)
self.interactive = False
if path != None:
_lib.load_json(self.obj_ptr, path)

Expand All @@ -397,6 +399,7 @@ def close(self):
del(self.obj_ptr)

def stop(self):
self.interactive = False
_lib.renderer_stop(self.obj_ptr)

def restart(self):
Expand All @@ -409,6 +412,7 @@ def render(self):
_lib.renderer_render(self.obj_ptr)

def start_interactive(self):
self.interactive = True
_lib.renderer_start_interactive(self.obj_ptr)

def get_result(self):
Expand All @@ -423,7 +427,7 @@ def get_result(self):
return ret_bitmap

def scene_get(self):
return scene(_lib.renderer_scene_get(self.obj_ptr))
return scene(self.obj_ptr)

def debug_dump(self):
_lib.debug_dump_state(self.obj_ptr)
Expand Down

0 comments on commit 284c616

Please sign in to comment.