Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def update(self):
- VMSG = " (verbose message in update)"
- pgp = self.player_glop.properties
- dd = debug_dict
- sg = self.settings['globals']
- sw = self.settings['world']
- # KivyGlops.update is called by KivyGlopsWindow.*update*
- # such as update_glsl
- # super(KivyGlops, self).update()
- # region pre-bump ops
- # NOT: tried to move regions "pre-bump ops" and
- # "bump loop" to pyglops but didn't work well
- # print("coords:"+str(Window.mouse_pos))
- # see also asp and clip_top in init
- # screen_w_arc_theta = 32.0
- # # actual number is fromprojectionMatrix matrix
- # screen_h_arc_theta = 18.0
- # # actual number is from projectionMatrix matrix
- global missing_bumper_warning_enable
- global missing_bumpable_warning_enable
- global missing_radius_warning_enable
- doneGIs = set()
- failsafe = False
- if failsafe:
- sg = {
- 'camera_perspective_number': self.CAMERA_FIRST_PERSON(),
- }
- sw = {
- 'gravity': 9.8,
- 'ground': 0.0,
- 'friction_divisor': 1.2, # a.k.a. wfd
- }
- for a_i_i in range(0, len(self._actor_indices)):
- a_index = self._actor_indices[a_i_i]
- if a_i_i in doneGIs:
- raise RuntimeError("{} is in _actor_indices more than"
- " once.".format(a_i_i))
- doneGIs.add(a_i_i)
- if a_index is None:
- continue
- actor_glop = self.glops[a_index]
- ags = actor_glop.state
- agp = actor_glop.properties
- agad = actor_glop.actor_dict
- a_name = actor_glop.name
- if agad is None:
- print("[ KivyGlops ] error in update: "
- "actor_dict is None for bumper named '"
- + str(actor_glop.name) + "'")
- continue
- if agad.get("ai_enable") is not None:
- self.on_process_ai(a_index)
- # NOTE: moveto_index and target_index are guaranteed
- # to exist by set_as_actor_at
- if agad['target_index'] is not None:
- agad['target_pos'] = \
- self.glops[agad['target_index']]._t_ins.xyz
- elif agad['moveto_index'] is not None:
- targetG = self.glops[agad['moveto_index']]
- if not targetG.state['visible_enable']:
- agad['moveto_index'] = None
- if get_verbose_enable():
- print("[ KivyGlops ] (verbose message)"
- " actor lost target since glop at"
- " moveto_index is now invisible")
- else:
- agad['target_pos'] = targetG._t_ins.xyz
- if agad['target_pos'] is not None:
- ags['acquire_radius'] = agp['reach_radius']
- src_pos = actor_glop._t_ins.xyz
- dst_pos = agad['target_pos']
- # acquire_radius is changed below if ranged weapon
- distance = get_distance_vec3_xz(src_pos, dst_pos)
- ags['desired_use'] = None
- ags['choice_ii'] = -1 # inventory index
- if agad.get('target_index') is not None:
- weapon_index = None
- # NOTE: uses is determined by item_dict,
- # ranges is by actor_dict (unless use contains
- # "shoot_", then ranges are determined by
- # item_dict)
- # Start desired_* as None in case item is no
- # longer in inventory.
- agadII = agad['inventory_index']
- if agadII >= 0:
- try_item = agad['inventory_items'][agadII]
- if 'uses' in try_item:
- for this_use in try_item['uses']:
- if this_use in sg['attack_uses']:
- ags['desired_use'] = this_use
- # attack guarantees
- # attack_types exists
- # (via set_as_item)
- ags['choice_ii'] = agadII
- # ^ guaranteed to exist by
- # set_as_actor_at
- # TODO: loop again and look for melee
- # else item has no use
- if agad['choice_ii'] < 0:
- # If weapon is not selected, choose
- # random weapon even if selected a slot.
- dii, du = actor_glop.find_item_with_any_use(
- sg['attack_uses']
- )
- ags['choice_ii'] = dii
- ags['desired_use'] = du
- if ags['choice_ii'] >= 0:
- if "shoot_" in this_use:
- range_for_use = None
- ranges_for_it = try_item.get('ranges')
- if ranges_for_it is not None:
- range_for_use = \
- ranges_for_it.get(this_use)
- if ranges_for_it is not None:
- ags['acquire_radius'] = range_for_use
- else:
- # TODO: predict arc to determine
- # range instead
- ags['acquire_radius'] = 20.
- if get_verbose_enable():
- print(
- "[ KivyGlops ]" + VMSG
- + " used default acquire"
- " radius "
- + str(ags['acquire_radius'])
- + " since item['ranges']['"
- "{}'] wasn't set"
- "".format(this_use)
- )
- else:
- if this_use in agad['ranges']:
- ags['acquire_radius'] = \
- agad['ranges'][this_use]
- else:
- # TODO: predict arc to determine
- # range instead
- ags['acquire_radius'] = 20.
- if get_verbose_enable():
- print(
- "[ KivyGlops ]"
- + VMSG + " used"
- " default acquire"
- " radius "
- + str(ags['acquire_radius'])
- + " since"
- " actor_dict['ranges']['"
- + "{}'] wasn't set"
- "".format(this_use)
- )
- else:
- ags['acquire_radius'] = agp['reach_radius']
- # ACTUAL MOVEMENT is done further down,
- # in `region choice-based movement and physics`
- # end for a_i_i (actor)
- self.on_update_glops()
- # endregion pre-bump ops
- # NOTE: (ANOTHER non-nested LOOP is at end of update,
- # for physics and unit movement)
- # region nested bump loop
- for detectable_i_i in range(0, len(self._bumpable_indices)):
- bumpable_index = self._bumpable_indices[detectable_i_i]
- if bumpable_index is None:
- continue
- d_glop = self.glops[bumpable_index]
- # ^ item_glop (d for detected, formerly e for bumpee)
- # For old variable names see
- # <https://github.com/poikilos/KivyGlops/blob/
- # 9d3b64faf255869cb94de67114fef35a616bb95e/kivyglops.py>.
- dgn = d_glop.name
- # ^ bumpable_name (detected glop name)
- dgp = d_glop.properties
- dgs = d_glop.state
- if not dgp['bump_enable']:
- continue
- for bumper_i_i in range(0, len(self._bumper_indices)):
- bumper_index = self._bumper_indices[bumper_i_i]
- if bumper_index is None:
- continue
- actor_glop = self.glops[bumper_index]
- bgp = actor_glop.properties
- bgn = actor_glop.name
- # ^ bumper_name (formerly r for bumper)
- distance = get_distance_kivyglops(d_glop, actor_glop)
- if dgp['hit_radius'] is None:
- if missing_radius_warning_enable:
- print("[ KivyGlops ] WARNING in update: Missing"
- " radius while bumped bumpable named "
- + str(dgn))
- missing_radius_warning_enable = False
- continue
- total_hit_radius = 0.0
- if d_glop.projectile_dict is not None:
- total_hit_radius = (
- dgp['hit_radius'] + bgp['hit_radius']
- )
- else:
- try:
- total_hit_radius = (
- dgp['hit_radius'] + bgp['reach_radius']
- )
- except KeyError:
- total_hit_radius = dgp['hit_radius']
- print("ERROR in detectable_i_i loop:"
- " reach_radius is "
- + str(bgp.get('reach_radius'))
- + " for glop named " + bgn
- + " but actor's should never be None")
- if distance <= total_hit_radius:
- # print("total_hit_radius:" + str(total_hit_radius))
- if bumper_index in dgs['in_range_indices']:
- # print("not out of range yet")
- continue
- # (only bump if ever moved out of range of it)
- if bumper_index == bumpable_index:
- # can't bump self
- continue
- if get_verbose_enable():
- print("[ KivyGlops ]" + VMSG + "'"
- + str(bgn) + "' in range of '"
- + str(dgn) + "'")
- if bgp['bump_enable']:
- if ((d_glop.projectile_dict is None)
- or (bgp['hitbox'] is None)
- or hitbox_contains_vec3(bgp['hitbox'],
- d_glop._t_ins.xyz)):
- dgs['bumped_by_index'] = bumper_index
- dgs['at_rest_event_enable'] = True
- else:
- # global out_of_hitbox_note_enable
- # if out_of_hitbox_note_enable:
- print("[ KivyGlops ]"
- " (debug only--this"
- " is normal) within"
- " total_hit_radius,"
- " but detectable at "
- + str(d_glop.get_pos()) + " is"
- " not in bumper's"
- " hitbox: "
- + str(bgp['hitbox']))
- # out_of_hitbox_n
- # ote_enable = False
- else:
- if get_verbose_enable():
- print("[ KivyGlops ]"
- + VMSG + "'"
- + str(bgn)
- + "' is not a bumper.")
- if bumper_index not in dgs['in_range_indices']:
- dgs['in_range_indices'].append(bumper_index)
- else:
- if bumper_index in dgs['in_range_indices']:
- dgs['in_range_indices'].remove(bumper_index)
- # end for bumper
- # end for bumpable
- # endregion nested bump loop
- # (ANOTHER non-nested LOOP is at end of update,
- # for physics and unit movement)
- # NOTE: hit detection above (such as item hitting enemy)
- # can make the item no longer bumpable or bumper,
- # so check for None:
- for j in reversed(range(len(self._bumpable_indices))):
- if self._bumpable_indices[j] is None:
- del(self._bumpable_indices[j])
- for j in reversed(range(len(self._bumper_indices))):
- if self._bumper_indices[j] is None:
- del(self._bumper_indices[j])
- # region choice-based movement and physics
- # --in that order, so you don't go through stuff
- got_frame_delay = 0.0
- # ^ do NOT move this to anywhere before hit
- # detection is finished--otherwise
- # invisible movement could occur (ones
- # using got_frame_delay) before hit
- # detection
- if self.last_update_s is not None:
- got_frame_delay = best_timer() - self.last_update_s
- self.last_update_s = best_timer()
- if not self._delay_is_available_enable:
- # prevent useless work and 0 movement warnings
- # by stopping here if got_frame_delay 0 is expected
- self._delay_is_available_enable = True
- return
- pgi = self.get_player_glop_index(1)
- p1motivated = False
- for motivated_index in range(len(self.glops)):
- if motivated_index is None:
- continue
- p1_enable = False
- if motivated_index == pgi:
- p1_enable = True
- if p1motivated:
- raise RuntimeError("p1 was already moved")
- p1motivated = True
- m_glop = self.glops[motivated_index]
- mgs = m_glop.state
- mgp = m_glop.properties
- mgid = m_glop.item_dict
- mgad = m_glop.actor_dict
- sta = self.settings['templates']['actor']
- lups = None # land units per second
- if mgad is not None:
- lups = mgad.get('land_speed')
- if lups is None:
- lups = sta['land_speed']
- # land units per frame:
- land_units_this_frame = lups * got_frame_delay
- if land_units_this_frame <= 0.:
- land_units_this_frame = 0.
- global show_zero_walk_upf_warning_enable
- if show_zero_walk_upf_warning_enable:
- print("[ KivyGlops ] WARNING in update: zero "
- "land units per frame (" + tltf + ")")
- show_zero_walk_upf_warning_enable = False
- laps = None # land acceleration units per second squared
- if mgad is not None:
- laps = mgad.get('land_accel')
- if laps is None:
- laps = sta['land_accel']
- lapf = laps * got_frame_delay # land accel per frame
- ldps = None # land degrees per second
- if mgad is not None:
- ldps = mgad.get('land_degrees_per_second')
- if ldps is None:
- ldps = sta['land_degrees_per_second']
- # land radians per frame:
- lrpf = math.radians(ldps) * got_frame_delay
- if lrpf <= 0.:
- lrpf = 0.
- global show_zero_degrees_pf_warning_enable
- if show_zero_degrees_pf_warning_enable:
- print("[ KivyGlops ] WARNING in update: zero "
- "land degrees per frame (this is the last "
- "time this message will be shown)")
- show_zero_degrees_pf_warning_enable = False
- # NOTE: Increased z should move object closer to viewer
- # in right-handed coordinate system
- choice_local_vel_mult = [0., 0., 0.]
- # ^ 1.0 is max joystick tilt: normally [0],[2]
- if 'dst_angles' not in mgs:
- mgs['dst_angles'] = None
- # mgs['look_theta_multipliers'] = [0., 0., 0.]
- mgas = m_glop.get_angles()
- if mgad is not None and mgad.get('target_pos') is not None:
- # If has target_pos, auto-move to target without
- # intervention even if is player-controlled glop.
- src_pos = m_glop.get_pos()
- dst_pos = mgad['target_pos']
- mgs['dst_angles'] = get_angles_vec3(
- src_pos,
- dst_pos,
- m_glop.get_angles()
- )
- distance = get_distance_vec3_xz(src_pos, dst_pos)
- tilt = .5
- run_enable = False
- sneak_enable = False
- if mgs.get('acquire_radius') is not None:
- # if mgad['target_index'] is None:
- run_enable = True
- if run_enable:
- tilt *= 2.
- if sneak_enable:
- tilt /= 2.
- if distance > mgs['acquire_radius']:
- # # global velocity
- # vmx, vmy = get_rect_from_polar_rad(
- # tilt, mgas[1])
- # # use current y angle
- # # to prevent instant strafe
- # choice_local_vel_mult[0] = vmx
- # choice_local_vel_mult[2] = vmy
- # local velocity
- choice_local_vel_mult[2] = tilt
- if mgad['target_index'] is not None:
- # If has weapon and attack target, auto-attack
- # even if is player-controlled glop
- if mgs['choice_ii'] >= 0:
- try:
- self.use_item_at(
- m_glop,
- mgs['choice_ii'],
- this_use=mgs['desired_use']
- )
- except:
- print("[ KivyGlops ] "
- "ERROR in update--"
- "could not finish"
- " using item "
- + str(mgs.get('choice_ii')))
- view_traceback()
- else:
- if not mgad['unarmed_melee_enable']:
- mgad['target_index'] = None
- else:
- print("[ KivyGlops ] ERROR in update:"
- " 'target_pos' was set but the engine"
- " forgot to calculate 'acquire_radius'")
- elif p1_enable:
- # for keycode strings, see
- # http://kivy.org/docs/_modules/kivy/core/window.html
- # TODO: make a virtual joystick for touch, and
- # (set mgs['look_theta_multipliers'] or
- # do math right away and) set look_dest_theta
- # (and the longer you press before tilting, the faster
- # the speed; start moving automatically at .5 sec
- # OPTION 2: double-tap to not move--but start
- # accelerating immediately while down even then)
- tilt = .5
- if self.player1_controller._get_key_state_at(
- self.ui.get_keycode("ctrl")):
- tilt /= 2.
- if self.player1_controller._get_key_state_at(
- self.ui.get_keycode("shift")):
- tilt *= 2.
- if self.player1_controller._get_key_state_at(
- self.ui.get_keycode("a")):
- choice_local_vel_mult[0] = -1.
- # ^ full speed so same as virtual shoulder button
- elif self.player1_controller._get_key_state_at(
- self.ui.get_keycode('d')):
- choice_local_vel_mult[0] = 1.
- # ^ full speed so same as virtual shoulder button
- if self.player1_controller._get_key_state_at(
- self.ui.get_keycode("w")):
- # if get_verbose_enable():
- # chatter()
- # if self.get_fly_by_name(m_glop.name):
- # # intentionally use z,y:
- # vmz, vmy = get_rect_from_polar_rad(
- # tilt, m_glop._r_ins_x.angle)
- # choice_local_vel_mult[2] = vmz
- # choice_local_vel_mult[1] = vmy
- # else:
- choice_local_vel_mult[2] = tilt
- elif self.player1_controller._get_key_state_at(
- self.ui.get_keycode('b')):
- if get_verbose_enable():
- breakpoint()
- elif self.player1_controller._get_key_state_at(
- self.ui.get_keycode('s')):
- # if self.get_fly_by_name(m_glop.name):
- # # intentionally use z,y:
- # opposite = math.radians(-180)
- # if m_glop._r_ins_x.angle < 0:
- # opposite *= -1.
- # vmz, vmy = get_rect_from_polar_rad(
- # tilt, m_glop._r_ins_x.angle + opposite)
- # choice_local_vel_mult[2] = vmz
- # choice_local_vel_mult[1] = vmy
- # else:
- choice_local_vel_mult[2] = -tilt
- pstep(debug_dict,
- pre="player controlling " + m_glop.name)
- if self.player1_controller._get_key_state_at(
- self.ui.get_keycode("enter")):
- self.use_selected(m_glop)
- if self.player1_controller._get_key_state_at(
- self.ui.get_keycode("spacebar")):
- if mgs['on_ground_enable']:
- # TODO: make double-jump event handler
- choice_local_vel_mult[1] = 1.
- # if get_verbose_enable():
- # print("[ KivyGlops ] (verbose message"
- # " in update: jumped (maximum try)")
- else:
- # if get_verbose_enable():
- # print("[ KivyGlops ] (verbose message"
- # " in update: can't jump while"
- # " not on ground.")
- pass
- # # DO NO MORE HIT DETECTION SINCE 1ST CHANGE IS BELOW
- # pstep(debug_dict, pre=("player controlling"
- # + self.glops[motivated_index].name))
- # ACTUAL MOVEMENT is done only if the object is at rest
- # (see else case below).
- check_pos_enable = False
- choice_moved_enable = False
- choice_world_vel = [0.0, 0.0, 0.0]
- # if m_glop.look_target_glop is not None:
- # m_glop.look_at(m_glop.look_target_glop)
- # print(str(m_glop.name) + " looks at " +
- # str(m_glop.look_target_glop.name))
- # print(
- # " at " +
- # str(
- # get_vec3_from_point(self.camera_glop._t_ins))
- mgsv = None
- try:
- mgsv = mgs['velocity']
- except KeyError:
- raise KeyError("(FATAL) state template was not applied"
- " to glop named {} from file '{}' but"
- " physics-enabled glop must always have"
- " velocity".format(m_glop.name, m_glop.source_path)
- )
- ar_enable = False
- choice_world_vel_mult = None
- if mgs['on_ground_enable'] or \
- self.get_fly_by_name(m_glop.name):
- ar_enable = True
- # can control own movement
- # (do not use look_dest_theta directly since wasn't
- # turned all the way in that direction until after the
- # movement below could have taken place)
- # xz coords of edges of 16x16 square are:
- # move in the direction you are facing
- choice_world_vel_mult = [0., 0., 0.]
- if choice_local_vel_mult[0] != 0.0 or \
- choice_local_vel_mult[1] != 0.0 or \
- choice_local_vel_mult[2] != 0.0:
- # makes movement relative to rotation
- # (which also limits speed when moving diagonally):
- moving_r_multiplier = \
- math.sqrt((choice_local_vel_mult[0]
- * choice_local_vel_mult[0])
- + (choice_local_vel_mult[2]
- * choice_local_vel_mult[2]))
- if moving_r_multiplier > 1.0:
- moving_r_multiplier = 1.0
- # Limited so that you can't move faster
- # when moving diagonally
- # print("[ KivyGlops ] WARNING in update:"
- # " clipped >100% movement")
- choice_world_vel_mult[0] = (moving_r_multiplier
- * math.cos(mgas[1]))
- # TODO: (?) make relative to rotation for fly mode:
- choice_world_vel_mult[1] = choice_local_vel_mult[1]
- choice_world_vel_mult[2] = (moving_r_multiplier
- * math.sin(mgas[1]))
- # choice_local* VARS SHOULD NOT BE USED AFTER THIS
- # SINCE THEY ARE NOT NEEDED FOR ANYTHING ELSE.
- choice_world_r_vel = lapf * moving_r_multiplier
- radial_xz_velocity = (
- math.sqrt((mgsv[0] * mgsv[0])
- + (mgsv[2] * mgsv[2]))
- )
- if choice_world_r_vel + radial_xz_velocity < -lapf:
- choice_world_r_vel = 0.
- # choice_world_r_vel += (
- # (choice_world_r_vel +
- # radial_xz_velocity) -
- # lapf
- # )
- elif choice_world_r_vel + radial_xz_velocity > lapf:
- choice_world_r_vel = 0.
- # choice_world_r_vel -= (
- # (choice_world_r_vel +
- # radial_xz_velocity) -
- # lapf
- # )
- if choice_world_r_vel < kEpsilon:
- choice_world_r_vel = 0.0
- pstep(debug_dict, pre="m_glop " + m_glop.name)
- # TODO: reprogram so adding math.radians(-90)
- # is not needed (?) or remove these comments if
- # works now
- # choice_world_vel[0] = \
- # lapf*moving_r_multiplier * \
- # math.cos(
- # m_glop._r_ins_y.angle +
- # mgas[1] +
- # math.radians(-90))
- # choice_world_vel[1] = (lapf
- # * choice_world_vel_mult[1])
- # choice_world_vel[2] = \
- # lapf * moving_r_multiplier * \
- # math.sin(m_glop._r_ins_y.angle +
- # mgas[1] +
- # math.radians(-90))
- for a_i in range(3):
- choice_world_vel[a_i] = (
- choice_world_vel_mult[a_i]
- * lapf # land accel per frame
- )
- # choice_world_vel[a_i] = 0.0 # debug only
- totalDelta = get_distance_vec3(choice_world_vel,
- (0, 0, 0))
- if totalDelta > .1:
- print("WARNING: choice_world_vel is too large: "
- "{}".format(choice_world_vel))
- # ^ moving too fast
- # choice_world_vel[0] = (choice_world_r_vel
- # * math.cos(mgas[1])
- # )
- # choice_world_vel[1] = (lapf
- # * choice_world_vel_mult[1]
- # )
- # choice_world_vel[2] = (choice_world_r_vel
- # * math.sin(mgas[1])
- # )
- # if (m_glop._t_ins.x + move_by_x > \
- # self._world_cube.get_max_x()):
- # move_by_x = \
- # self._world_cube.get_max_x() - \
- # m_glop._t_ins.x
- # print(str(m_glop._t_ins.x) + " of max_x:" +
- # str(self._world_cube.get_max_x()))
- # if (m_glop._t_ins.z + move_by_z > \
- # self._world_cube.get_max_z()):
- # move_by_z = self._world_cube.get_max_z() - \
- # m_glop._t_ins.z
- # print(str(m_glop._t_ins.z) + " of max_z:" +
- # str(self._world_cube.get_max_z()))
- # if (m_glop._t_ins.x + move_by_x < \
- # self._world_cube.get_min_x()):
- # move_by_x = self._world_cube.get_min_x() - \
- # m_glop._t_ins.x
- # print(str(m_glop._t_ins.x) + " of max_x:" +
- # str(self._world_cube.get_max_x()))
- # if (m_glop._t_ins.z + move_by_z < \
- # self._world_cube.get_min_z()):
- # move_by_z = self._world_cube.get_min_z() - \
- # m_glop._t_ins.z
- # print(str(m_glop._t_ins.z) + " of max_z:" +
- # str(self._world_cube.get_max_z()))
- # print(str(m_glop._t_ins.xz) + " each " +
- # "coordinate should be between matching" +
- # " one in " +
- # str(self._world_cube.get_min_x()) + "," +
- # str(self._world_cube.get_min_z()) +
- # " and " +
- # str(self._world_cube.get_max_x()) + "," +
- # str(self._world_cube.get_max_z()))
- # print(str(m_glop._t_ins.xyz) + " each " +
- # "coordinate should be between matching" +
- # " one in " +
- # str(self.world_boundary_min) +
- # " and " +
- # str(self.world_boundary_max))
- for axis_i in range(0, 3):
- if choice_world_vel[axis_i] != 0.0:
- choice_moved_enable = True
- mgsv[axis_i] += choice_world_vel[axis_i]
- if mgsv[axis_i] != 0.0:
- # set _t_ins via set_coord:
- m_glop.set_coord(axis_i, mgsv[axis_i])
- # pstep(debug_dict, pre="m_glop " + m_glop.name)
- # self.prev_inbounds_camera_translate = \
- # self.camera_glop._t_ins.x,
- # self.camera_glop._t_ins.y,
- # self.camera_glop._t_ins.z
- # else:
- # self.camera_glop._t_ins.x += \
- # self.land_units_this_frame * \
- # choice_local_vel_mult[0]
- # self.camera_glop._t_ins.z += \
- # self.land_units_this_frame * \
- # choice_local_vel_mult[2]
- # TODO:? if mgs['look_theta_multipliers'][1] != 0.0:
- # delta_y = lrpf * choice_try_theta_multipliers[1]
- # m_glop._r_ins_y.angle += delta_y
- # if choice_try_theta_multipliers is not None:
- # choice_world_turn_theta = \
- # choice_try_theta_multipliers[1]
- if mgs['dst_angles'] is not None:
- # if land_units_this_frame is not None:
- for a_i in range(3):
- delta_theta = mgs['dst_angles'][a_i] - mgas[a_i]
- if delta_theta > lrpf:
- delta_theta = lrpf
- elif delta_theta < -lrpf:
- delta_theta = -lrpf
- # check kEpsilon to prevent jitter while stopped
- if delta_theta > kEpsilon or \
- delta_theta < -kEpsilon:
- new_a = mgas[a_i] + delta_theta
- m_glop.set_angle(a_i, new_a)
- if p1_enable and a_i == 1:
- if not fequals(m_glop.get_angle(a_i),
- new_a):
- # print(
- # "FAILED to set angle " +
- # str(math.degrees(
- # m_glop.get_angle(a_i))) +
- # " to " +
- # str(math.degrees(new_a)))
- print("FAILED to set angle "
- + str(m_glop.get_angle(a_i))
- + " to "
- + str(new_a))
- # TODO: m_glop._r_ins_y.angle = \
- # angle_trunc(m_glop._r_ins_y.angle)
- # m_glop._t_ins.x += \
- # choice_local_vel_mult[0]
- # m_glop._t_ins.z += \
- # choice_local_vel_mult[2]
- # else:
- # print("[ KivyGlops ] ERROR in update:"
- # " choice_world_turn_theta was set"
- # " for unit, but engine forgot to set"
- # " land_units_this_frame")
- # end if on_ground_enable or flying can control own movement
- # pstep(debug_dict, pre="m_glop " + m_glop.name)
- pcgs = None # player-controlled glop state
- if p1_enable:
- if sg['camera_perspective_number'] == \
- self.CAMERA_FIRST_PERSON():
- # player-controlled glop
- pcgs = self.player_glop.state
- else:
- pcgs = self.camera_glop.state
- if pcgs is not None and \
- pcgs.get('dst_angles') is not None:
- if 'Player' not in debug_dict:
- debug_dict['Player'] = {}
- pcg = None
- if pcgs.get('glop_index') is not None:
- pcg = self.glops[pcgs['glop_index']]
- debug_dict['Player']['name'] = pcg.name
- debug_dict['Player']['angles'] = \
- fixed_width(
- degrees_list(
- pcg.get_angles()), 6, " ")
- debug_dict['Player']['dst_angles'] = \
- fixed_width(
- degrees_list(
- pcgs['dst_angles']), 6, " ")
- debug_dict['Player']['free'] = ar_enable
- if choice_moved_enable:
- check_pos_enable = True
- # if (not mgs['on_ground_enable']) or \
- # choice_moved_enable:
- # if not mgs['on_ground_enable']:
- # if m_glop._cached_floor_y is None:
- # m_glop._cached_floor_y = self._world_min_y
- # # TODO: get from walkmesh instead and
- # # eliminate _cached_floor_y
- # (this part is under no outer conditions)
- # pstep(debug_dict, pre="m_glop " + m_glop.name)
- if mgp['physics_enable']:
- # TODO: Fix issue where can't move if physics_enable is
- # false
- if mgs.get('show_physics_msg_enable') is None:
- if get_verbose_enable():
- print("[ KivyGlops ] (verbose message "
- "in update) processing first run of"
- " physics for " + m_glop.name)
- mgs['show_physics_msg_enable'] = True
- # walk_info = \
- # self.constrain_glop_to_walkmesh(m_glop)
- # on_ground_enable = \
- # walk_info.get('on_ground_enable')
- # if on_ground_enable is not None:
- # if mgs['on_ground_enable'] != \
- # on_ground_enable:
- # mgs['on_ground_enable'] = \
- # on_ground_enable
- # mgs['at_rest_event_enable'] = \
- # True
- # deprecated this_glop_free_enable = False
- # if m_glop._cached_floor_y is not None:
- # if m_glop._t_ins.y - mgp['hit_radius'] - \
- # kEpsilon > m_glop._cached_floor_y:
- # # this_glop_free_enable = True
- # pass
- # else: # STOP object
- # # (remove owner and projectile_dict)
- # mgs['on_ground_enable'] = True
- # else:
- # pass
- # # no cached floor, so move without regard to
- # # ground
- # # this_glop_free_enable = True
- if mgs['at_rest_event_enable']:
- # HIT GROUND (or target if
- # mgs.get('bumped_by_index') \
- # is not None
- mgs['at_rest_event_enable'] = False
- bumper_index = mgs.get('bumped_by_index')
- d_glop = None
- r_glop = None
- egp = None
- rgp = None
- if bumper_index is not None:
- self.on_bump(motivated_index, bumper_index)
- bumpable_index = motivated_index
- d_glop = self.glops[bumpable_index]
- r_glop = self.glops[bumper_index]
- egp = d_glop.properties
- rgp = r_glop.properties
- else:
- self.on_bump_world(motivated_index, 'ground')
- bumper_index = motivated_index
- bumpable_index = None
- r_glop = self.glops[bumper_index]
- rgp = r_glop.properties
- # TODO: optionally, such as for bottom-heavy
- # items: m_glop._r_ins_x.angle = 0.
- # if mgsv[2] > kEpsilon:
- # if (mgsv[1] < 0.0 - \
- # (kEpsilon + mgp['hit_radius'])):
- # print(" HIT GROUND Y:" +
- # str(m_glop._cached_floor_y))
- # bump_sound_paths is guaranteed by PyGlop
- # _init_glop to exist in glop's properties
- if d_glop is not None:
- bsps = egp['bump_sound_paths']
- if len(bsps) > 0:
- rand_i = random.randrange(
- 0, len(bsps))
- self.play_sound(bsps[rand_i])
- igpd = d_glop.projectile_dict
- # NOTE: already checked
- # bumpable_index bump_enable above
- # print("distance:" + str(total_hit_radius) +
- # " <= total_hit_radius:" +
- # str(total_hit_radius))
- if igpd is None or \
- ('owner' not in igpd) or \
- (igpd['owner'] != r_glop.name):
- self._internal_bump_glop(bumpable_index,
- bumper_index)
- if get_verbose_enable():
- if d_glop is not None:
- print("[ KivyGlops ]" + VMSG
- + str(r_glop.name)
- + " bumped "
- + str(d_glop.name))
- elif r_glop is not None:
- print("[ KivyGlops ]" + VMSG
- + str(r_glop.name)
- + " bumped world")
- else:
- if get_verbose_enable():
- print("[ KivyGlops ]" + VMSG
- + "cannot bump own projectile")
- # NOTE: projectile_dict is already removed above
- # by _internal_bump_glop if relevant
- if mgid is not None:
- if mgid['state'].get('owner') is not None:
- del mgid['state']['owner']
- if mgid['state'].get('owner_key') is not None:
- del mgid['state']['owner_key']
- # m_glop._t_ins.y = m_glop._cached_floor_y +
- # mgp['hit_radius']
- # check_pos_enable = True
- # if mgsv[0] != 0. or \
- # mgsv[1] != 0. or \
- # mgsv[2] != 0.:
- # if get_verbose_enable():
- # print("[ KivyGlops ] stopped glop" +
- # "{hit_radius:" +
- # str(mgp['hit_radius']) +
- # "; glop._cached_floor_y:" +
- # str(m_glop._cached_floor_y) +
- # "}")
- mgsv[1] = 0.0
- # end if mgs['at_rest_event_enable']
- # (still inside `if...physics_enable`--and only that)
- if mgs['on_ground_enable']:
- wfd = sw['friction_divisor']
- wfdp = wfd
- if mgsv[1] < -kEpsilon:
- wfdp = wfd + -mgsv[1]
- # ^ pressure increases friction
- # TODO: real physics for wfdp
- if mgsv[1] <= kEpsilon:
- # if no upward velocity, do friction
- if mgsv[0] > kEpsilon:
- mgsv[0] /= wfdp
- else:
- mgsv[0] = 0.
- # mgsv[1] is done later,
- # based on gravity
- if mgsv[2] > kEpsilon:
- mgsv[2] /= wfdp
- else:
- mgsv[2] = 0.
- # this_glop_free_enable = False
- src_pos = m_glop.get_pos()
- dst_pos = (
- src_pos[0] + mgsv[0] * got_frame_delay,
- src_pos[1] + mgsv[1] * got_frame_delay,
- src_pos[2] + mgsv[2] * got_frame_delay
- )
- '''
- if get_verbose_enable():
- print("CHANGING {} dst_pos to {} using src_pos {}"
- " + mgsv {} * {}..."
- "".format(m_glop.name, dst_pos, src_pos, mgsv,
- got_frame_delay))
- '''
- if get_verbose_enable():
- if mgad is not None and mgp['roll_enable']:
- print("[ KivyGlops ] WARNING in update:"
- " roll_enable is True for actor"
- " '{}'".format(m_glop.name))
- if mgs['on_ground_enable'] and \
- (mgp.get('hit_radius') is not None) and \
- (mgp['hit_radius'] > 0) and \
- mgp['roll_enable']:
- # ^ roll only if not actor (mgad is None)
- # TODO: Use rolling friction (here or elsewhere)
- # TODO: Project it into object space for accuracy
- angles = m_glop.get_angles()
- rolling_vec_indices = (0, 2)
- rvtis = (2, 1) # rolling vector theta indices
- rvps = ((0, 2), (1, 2)) # rolling vector planes
- for rvi in rolling_vec_indices:
- src_2D_pos = (src_pos[rvps[rvi][0]],
- src_pos[rvps[rvi][1]])
- dst_2D_pos = (dst_pos[rvps[rvi][0]],
- dst_pos[rvps[rvi][1]])
- # first do trig to get angle from pos delta:
- offset_theta = get_angle_vec2(src_2D_pos,
- dst_2D_pos)
- # <https://www.mathopenref.com/arclength.html>
- al = (TAU * mgp['hit_radius'] *
- (offset_theta / TAU))
- # Simplifies if have radians & central angle
- # but central angle is always acute
- # so doesn't provide info useful to engine:
- # al = mgp['hit_radius'] * offset_c
- angles[rvi] += al
- # TODO: why does changing rotation
- # make things hit ground too high?
- if (angles[rvi] > TAU):
- angles[rvi] -= TAU
- elif (angles[rvi] < NEG_TAU):
- angles[rvi] += TAU
- m_glop.set_angles(angles)
- # do even if 'on_ground_enable' since may be rolling
- m_glop.set_pos(dst_pos)
- debugKey = m_glop.name
- if debugKey == "Player 1":
- debugKey = "Player"
- if debugKey not in debug_dict:
- debug_dict[debugKey] = {}
- debug_dict[debugKey]['pos'] = m_glop.get_pos()
- if not mgs['on_ground_enable']:
- # process gravity only
- # (don't do hit detection again until user
- # [& ai at top of this method] sees this frame)
- if got_frame_delay > 0.0:
- check_pos_enable = True
- # print("[ KivyGlops ]" + VMSG +
- # "GRAVITY AFFECTED:" +
- # str(m_glop._t_ins.y) +
- # " += " + str(mgsv[1]))
- mgsv[1] -= sw['gravity'] * got_frame_delay
- # print("[ KivyGlops ]" + VMSG +
- # "THEN VELOCITY CHANGED TO:" +
- # str(mgsv[1]))
- # print("[ KivyGlops ]" + VMSG +
- # "FRAME INTERVAL:" +
- # str(got_frame_delay))
- else:
- if self._delay_is_available_enable:
- print("[ KivyGlops ] "
- "WARNING in update: no frame"
- " delay is detectable (update"
- " normally runs automatically"
- " once per frame but seems to"
- " be running more often)")
- # end if physics_enable
- # AND FORMERLY end on_ground_enable or choice_moved_enable
- # pstep(debug_dict, pre="m_glop " + m_glop.name)
- # if choice_local_vel_mult[0] != 0.0 or \
- # # choice_local_vel_mult[1] != 0.0 or \
- # # choice_local_vel_mult[2] != 0.0:
- # did NOT necessarily move (deltas already checked)
- if (not mgs['on_ground_enable']):
- if choice_world_vel[0] != 0.0 or \
- choice_world_vel[1] != 0.0 or \
- choice_world_vel[2] != 0.0:
- # then already did check_pos_enable when set
- if get_verbose_enable():
- prev_on_ground_enable = \
- mgs.get('prev_on_ground_enable')
- if prev_on_ground_enable != \
- mgs['on_ground_enable']:
- print("[ KivyGlops ]" + VMSG
- + "glop " + m_glop.name
- + " tried to move, but was not "
- "at rest (physics in control)")
- # pstep(debug_dict, pre="m_glop " + m_glop.name)
- '''
- # Confirmed: choice_world_vel and choice_world_vel_mult
- # only change for the player.
- dN = "glop[{}]".format(motivated_index)
- if pgi == motivated_index:
- dN += " (player)"
- debug_dict[dN] = {}
- ddG = debug_dict[dN]
- ddG['choice_world_vel'] = \
- choice_world_vel
- ddG['choice_world_vel_mult'] = \
- choice_world_vel_mult
- # ^ None unless controlled above (such as player 1)
- '''
- mgs['prev_on_ground_enable'] = mgs['on_ground_enable']
- mgs['constrained_enable'] = False
- # deprecated this_glop_free_enable
- # deprecated stop_this_bumpable_enable
- for rel in mgs['links']:
- if rel['r_type'] == "carry":
- if m_glop._t_ins.xyz != \
- rel['state']['parent_glop']._t_ins.xyz:
- m_glop._t_ins.x = \
- rel['state']['parent_glop']._t_ins.x
- m_glop._t_ins.y = \
- rel['state']['parent_glop']._t_ins.y
- m_glop._t_ins.z = \
- rel['state']['parent_glop']._t_ins.z
- check_pos_enable = True
- mgs['on_ground_enable'] = True
- mgs['constrained_enable'] = True
- else:
- print("[ KivyGlops ] ERROR in update: "
- "unknown link r_type "
- + str(rel.get('r_type')))
- # pstep(debug_dict, pre="m_glop " + m_glop.name)
- # if mgp['physics_enable']:
- if p1_enable:
- if 'Player' not in dd:
- dd['Player'] = {}
- dd['Player']['check_pos_enable'] = check_pos_enable
- if check_pos_enable and mgp['clip_enable']:
- const_ground_enable = True
- walk_info = None
- walkmesh_enable = True
- # ^ becomes False below if there are no walkmeshes
- if walkmesh_enable:
- if len(self._walkmeshes) > 0:
- const_ground_enable = False
- # constrained_pos = [m_glop._t_ins.x,
- # m_glop._t_ins.y,
- # m_glop._t_ins.z]
- if mgp['hitbox'] is not None:
- walk_info = self.get_walk_info(
- m_glop._t_ins.xyz,
- (mgp['hitbox']['maximums'][0],
- -mgp['hitbox']['minimums'][1])
- )
- else:
- walk_info = self.get_walk_info(
- m_glop._t_ins.xyz,
- (mgp['hit_radius'],
- mgp['hit_radius'])
- )
- if (motivated_index
- == self.get_player_glop_index(1)):
- if 'Player' not in dd:
- dd['Player'] = {}
- dd['Player']['walkmesh_via'] = \
- walk_info['walkmesh_via']
- dd['Player']['feet_y'] = walk_info['feet_y']
- else:
- walkmesh_enable = False
- if const_ground_enable:
- walk_info = {}
- walk_info['pos'] = [
- m_glop._t_ins.x,
- m_glop._t_ins.y,
- m_glop._t_ins.z
- ]
- walk_info['change_enable'] = False
- height_only_enable = True
- corrected_pos = [
- m_glop._t_ins.x,
- m_glop._t_ins.y,
- m_glop._t_ins.z
- ]
- if corrected_pos[1] < sw['ground']:
- corrected_pos[1] = sw['ground']
- hit_ground_enable = None
- if not height_only_enable:
- walk_info['change_enable'] = True
- walk_info['pos'][0] = corrected_pos[0]
- walk_info['pos'][2] = corrected_pos[2]
- # TODO: check y (vertical) axis against
- # eye height and jump height etc
- # region pasted from get_walk_info
- if walk_info['pos'][1] - corrected_pos[1] < \
- kEpsilon:
- walk_info['on_ground_enable'] = True
- elif walk_info['pos'][1] - corrected_pos[1] > \
- kEpsilon:
- # Hovering higher than kEpsilon--
- # use kEpsilon as a deadzone so that
- # floating point errors don't cause physics
- # and hence many at_rest events
- walk_info['on_ground_enable'] = False
- if corrected_pos[1] > walk_info['pos'][1]:
- walk_info['change_enable'] = True
- walk_info['pos'][1] = corrected_pos[1]
- else:
- # Hovering (previous if-else flags for physics)
- pass
- # endregion pasted from get_walk_info
- elif not walkmesh_enable:
- raise NotImplementedError(
- "Only walkmesh and const_ground_enable"
- " walk_info are implemented."
- )
- walk_info = {}
- walk_info['on_ground_enable'] = True
- walk_info['change_enable'] = False
- if get_verbose_enable():
- print("walkmesh_enable: {}".format(walkmesh_enable))
- on_ground_enable = walk_info.get('on_ground_enable')
- if on_ground_enable is not None:
- if mgs['on_ground_enable'] != on_ground_enable:
- mgs['on_ground_enable'] = on_ground_enable
- if on_ground_enable:
- mgs['at_rest_event_enable'] = True
- # frame of hit is shown to player and ai
- # BEFORE event is handled
- else:
- pass
- # mgs['not_at_rest_event_enable'] = True
- # TODO: (?) make an on_not_at_rest event
- if walk_info['change_enable']:
- if get_verbose_enable():
- print("{} walk_info:{}"
- "".format(m_glop.name, walk_info))
- # frame of hit is shown to player and ai
- # BEFORE event is handled
- m_glop._t_ins.x = walk_info['pos'][0]
- # if on_ground_enable is True:
- m_glop._t_ins.y = walk_info['pos'][1]
- m_glop._t_ins.z = walk_info['pos'][2]
- # end for motivated_index in glops
- # pstep(debug_dict, pre="m_glop " + m_glop.name)
- # movitated_glop out of scope
- # for index in self._bumper_indices:
- # m_glop = self.glops[index]
- # walk_info = self.constrain_glop_to_walkmesh(m_glop)
- # on_ground_enable = walk_info.get('on_ground_enable')
- # if on_ground_enable is not None:
- # if mgs['on_ground_enable'] != on_ground_enable:
- # mgs['on_ground_enable'] = on_ground_enable
- # print(
- # "[ KivyGlops ] WARNING: update changed" +
- # " rest state of " + m_glop.name + " to " +
- # str(on_ground_enable) + " but at_rest " +
- # "events were not fired nor was manual" +
- # " programming done (not yet implemented)")
- # endregion choice-based movement and physics
- if sg['camera_perspective_number'] == \
- self.CAMERA_FIRST_PERSON():
- self.camera_glop._t_ins.x = self.player_glop._t_ins.x
- self.camera_glop._t_ins.y = (self.player_glop._t_ins.y
- + pgp['eye_height'])
- self.camera_glop._t_ins.z = self.player_glop._t_ins.z
- self.camera_glop._r_ins_x.angle = \
- self.player_glop._r_ins_x.angle
- self.camera_glop._r_ins_y.angle = \
- self.player_glop._r_ins_y.angle
- self.camera_glop._r_ins_z.angle = \
- self.player_glop._r_ins_z.angle
- elif sg['camera_perspective_number'] == self.CAMERA_FREE():
- pass
- else:
- print("[ KivyGlops ] ERROR in update:"
- " settings['camera_perspective_number'] {}"
- " is not yet implemented. Try setting number to "
- " in scene to one of the self.CAMERA_*()"
- " methods' returns."
- "".format(sg['camera_perspective_number']))
- # pstep(debug_dict, pre="m_glop " + m_glop.name)
- asp = float(self.ui.width) / float(self.ui.height)
- clip_top = 0.06 # NOTE: 0.03 is ~1.72 degrees, if that matters
- # formerly field_of_view_factor
- # was changed to .03 when projection_near was changed from
- # 1 to .1
- # was .3 when projection_near was 1
- clip_right = asp*clip_top # formerly overwrote asp
- self.projectionMatrix = Matrix()
- self.modelViewMatrix = Matrix()
- # self.modelViewMatrix.rotate(
- # self.camera_glop._r_ins_x.angle,1.0,0.0,0.0)
- # self.modelViewMatrix.rotate(
- # self.camera_glop._r_ins_y.angle,0.0,1.0,0.0)
- # look_at(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY,
- # upZ) # http://kivy.org/docs/
- # # api-kivy.graphics.transformation.html
- # self.modelViewMatrix.rotate(self.camera_glop._r_ins_z.angle,
- # 0.0, 0.0, 1.0)
- previous_look_point = None
- if self.look_point is not None:
- previous_look_point = (
- self.look_point[0],
- self.look_point[1],
- self.look_point[2]
- )
- self.look_point = [0.0, 0.0, 0.0]
- # 0 is the angle (1, 2, and 3 are the matrix)
- self.look_point[0] = \
- (self.focal_distance
- * math.cos(self.camera_glop._r_ins_y.angle))
- self.look_point[2] = \
- (self.focal_distance
- * math.sin(self.camera_glop._r_ins_y.angle))
- # print("self.camera_glop._r_ins_y.angle: "
- # + str(self.camera_glop._r_ins_y.angle))
- # self.look_point[1] = 0.0
- # ^ (changed in "for" loop below) since y is up, and 1 is y,
- # ignore index 1 when we are rotating on that axis
- self.look_point[1] = \
- (self.focal_distance
- * math.sin(self.camera_glop._r_ins_x.angle))
- # self.modelViewMatrix = self.modelViewMatrix.look_at(
- # 0, self.camera_glop._t_ins.y,0, self.look_point[0],
- # self.look_point[1], self.look_point[2], 0, 1, 0)
- # Since camera's target should be relative to camera,
- # add camera's position:
- self.look_point[0] += self.camera_glop._t_ins.x
- self.look_point[1] += self.camera_glop._t_ins.y
- self.look_point[2] += self.camera_glop._t_ins.z
- # must translate first, otherwise look_at will override
- # position on rotation axis ('y' in this case)
- self.modelViewMatrix.translate(self.camera_glop._t_ins.x,
- self.camera_glop._t_ins.y,
- self.camera_glop._t_ins.z)
- self.modelViewMatrix = self.modelViewMatrix.look_at(
- self.camera_glop._t_ins.x,
- self.camera_glop._t_ins.y,
- self.camera_glop._t_ins.z,
- self.look_point[0],
- self.look_point[1],
- self.look_point[2],
- 0,
- 1,
- 0
- )
- # projectionMatrix.
- # view_clip(left, right, bottom, top, near, far, perspective)
- # "In OpenGL, a 3D point in eye space is projected onto the
- # near plane (projection plane)"
- # -http://www.songho.ca/opengl/gl_projectionmatrix.html
- # The near plane and far plane distances are in the -z direction
- # but are expressed as positive values since they are distances
- # from the camera then they are compressed to -1 to 1
- # -https://www.youtube.com/watch?v=frtzb2WWECg
- self.projectionMatrix = self.projectionMatrix.view_clip(
- -clip_right, clip_right, -1*clip_top, clip_top,
- self.projection_near,
- 100, # far
- 1, # perspective
- )
- top_theta = theta_radians_from_rectangular(
- self.projection_near, clip_top)
- right_theta = theta_radians_from_rectangular(
- self.projection_near, clip_right)
- self.ui.screen_w_arc_theta = right_theta*2.0
- self.ui.screen_h_arc_theta = top_theta*2.0
- glwCv = self.ui.gl_widget.canvas
- glwCv['projection_mat'] = self.projectionMatrix
- glwCv['modelview_mat'] = self.modelViewMatrix
- glwCv['camera_world_pos'] = self.camera_glop._t_ins.xyz
- # if get_verbose_enable():
- # Logger.debug("ok (update_glsl)")
- # is_look_point_changed = False
- # if previous_look_point is not None:
- # for axis_index in range(3):
- # if self.look_point[axis_index] != \
- # previous_look_point[axis_index]:
- # is_look_point_changed = True
- # # print(str(self.look_point) + " was " +
- # # str(previous_look_point))
- # break
- # else:
- # is_look_point_changed = True
- # if is_look_point_changed:
- # pass
- # # print("Now looking at " + str(self.look_point))
- # # print(
- # # "position: " +
- # # str(get_vec3_from_point(self.camera_glop._t_ins)" +
- # # "; self.camera_glop._r_ins_y.angle:" +
- # # str(self.camera_glop._r_ins_y.angle) +
- # # "(" +
- # # str(math.degrees(self.camera_glop._r_ins_y.angle)) +
- # # "degrees); moving_theta:" +
- # # str(math.degrees(moving_theta)) +
- # # " degrees")
- if ((self._previous_world_light_dir is None)
- or (self._previous_world_light_dir[0]
- != glwCv['_world_light_dir'][0])
- or (self._previous_world_light_dir[1]
- != glwCv['_world_light_dir'][1])
- or (self._previous_world_light_dir[2]
- != glwCv['_world_light_dir'][2])
- or (self._previous_camera_rotate_y_angle is None)
- or (self._previous_camera_rotate_y_angle
- != self.camera_glop._r_ins_y.angle)):
- # glwCv['_world_light_dir'] = (0.0, .5, 1.0)
- # glwCv['_world_light_dir_eye_space'] = (0.0, .5, 1.0)
- world_light_theta = theta_radians_from_rectangular(
- glwCv['_world_light_dir'][0],
- glwCv['_world_light_dir'][2]
- )
- light_theta = (world_light_theta
- + self.camera_glop._r_ins_y.angle)
- light_r = math.sqrt(
- (glwCv['_world_light_dir'][0]
- * glwCv['_world_light_dir'][0])
- + (glwCv['_world_light_dir'][2]
- * glwCv['_world_light_dir'][2])
- )
- glwCv['_world_light_dir_eye_space'] = (
- light_r * math.cos(light_theta),
- glwCv['_world_light_dir_eye_space'][1],
- light_r * math.sin(light_theta)
- )
- self._previous_camera_rotate_y_angle = \
- self.camera_glop._r_ins_y.angle
- self._previous_world_light_dir = (
- glwCv['_world_light_dir'][0],
- glwCv['_world_light_dir'][1],
- glwCv['_world_light_dir'][2]
- )
- # pstep(debug_dict, pre="m_glop " + m_glop.name)
- self._delay_is_available_enable = True
- self.update_view_visual_debug()
- # end update
Advertisement
Add Comment
Please, Sign In to add comment