Skip to content

Commit

Permalink
Inside viewer: abstracing values for camera body type.
Browse files Browse the repository at this point in the history
  • Loading branch information
unhyperbolic committed Nov 25, 2023
1 parent de05b8e commit 6409ba8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
8 changes: 6 additions & 2 deletions python/raytracing/eyeball.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

import math

eyeball_type_none = 0
eyeball_type_paper_plane = 1
eyeball_type_eyeball = 2

_max_num_eyeballs = 40

class Eyeball:
Expand All @@ -25,7 +29,7 @@ def __init__(self, raytracing_view):
def _enabled(self):
return (
self.raytracing_view.ui_parameter_dict['eyeballSize'][1] > 0 and
self.raytracing_view.ui_parameter_dict['eyeballType'][1] > 0)
self.raytracing_view.ui_parameter_dict['eyeballType'][1] > eyeball_type_none)

def get_compile_time_defs(self):
if not self._enabled():
Expand Down Expand Up @@ -62,7 +66,7 @@ def get_uniform_bindings(self):
min_inner_product = -RF(1.0 + 1e-7)

eyeballRadius = self.raytracing_view.ui_parameter_dict['eyeballSize'][1]
if self.raytracing_view.ui_parameter_dict['eyeballType'][1] == 2:
if self.raytracing_view.ui_parameter_dict['eyeballType'][1] == eyeball_type_eyeball:
eyeballRadius = eyeballRadius / 2.0
tets_to_data = [ [] for i in range(self.num_tetrahedra) ]

Expand Down
17 changes: 8 additions & 9 deletions python/raytracing/ideal_raytracing_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,15 +392,14 @@ def initial_view_state(self):
weight = 0.0
return (boost, tet_num, weight)

# def update_view_state(self, boost_tet_num_and_weight,
# m=matrix([[1.0, 0.0, 0.0, 0.0],
# [0.0, 1.0, 0.0, 0.0],
# [0.0, 0.0, 1.0, 0.0],
# [0.0, 0.0, 0.0, 1.0]])):
# boost, tet_num, weight = boost_tet_num_and_weight
# boost = boost * m
# return boost, tet_num, weight

def update_view_state(self, boost_tet_num_and_weight,
m=matrix([[1.0, 0.0, 0.0, 0.0],
[0.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0]])):
boost, tet_num, weight = boost_tet_num_and_weight
boost = boost * m
return boost, tet_num, weight

def _pgl2_matrix_for_face(tet, F):
gluing = tet.Gluing[F]
Expand Down
8 changes: 6 additions & 2 deletions python/raytracing/inside_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .geodesics_window import GeodesicsWindow
from .hyperboloid_utilities import unit_3_vector_and_distance_to_O13_hyperbolic_translation
from .zoom_slider import Slider, ZoomSlider
from .eyeball import eyeball_type_none, eyeball_type_paper_plane, eyeball_type_eyeball

try:
from math import gcd as _gcd
Expand Down Expand Up @@ -350,9 +351,12 @@ def create_eyeball_frame(self, parent):
self_type_label.grid(row=row, column=0)

radio_buttons = []
for i, text in enumerate(["None", "Paper plane", "Eyeball"]):
for i, (eyeball_type, text) in enumerate([
(eyeball_type_none, "None"),
(eyeball_type_paper_plane, "Paper plane"),
(eyeball_type_eyeball, "Eyeball")]):
button = ttk.Radiobutton(frame,
value=i,
value=eyeball_type,
text=text,
takefocus=0)
button.grid(row=row, column=1 + i, padx=8, sticky=tkinter.NW)
Expand Down
3 changes: 2 additions & 1 deletion python/raytracing/raytracing_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .hyperboloid_navigation import *
from .geodesics import Geodesics
from .eyeball import Eyeball
from .eyeball import eyeball_type_none, eyeball_type_paper_plane
from . import shaders

from snappy.CyOpenGL import SimpleImageShaderWidget
Expand Down Expand Up @@ -127,7 +128,7 @@ def __init__(self,
'geodesicTubeEnables' : ['bool[]', []],
'eyeballSize' : ['float', 0.5],
'freezeEyeball' : ['bool', False],
'eyeballType' : ['int', 0 if has_weights else 1]
'eyeballType' : ['int', eyeball_type_none if has_weights else eyeball_type_paper_plane]
}

if cohomology_class:
Expand Down

0 comments on commit 6409ba8

Please sign in to comment.