1
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: fix phasing though obstacles at high velocity

noxe-jkl b443b948 ac142bb6

+17 -5
+17 -5
physics_engine.vhd
··· 148 148 variable vx, vy : std_logic_vector(9 downto 0); 149 149 variable px, py : std_logic_vector(10 downto 0); 150 150 variable bounced : std_logic; 151 - variable bounce_wall : std_logic; 152 - variable bounce_speed : std_logic_vector(9 downto 0); 153 - variable grounded : std_logic; 151 + variable bounce_wall : std_logic; 154 152 variable c_left, c_right, c_top, c_bot : std_logic_vector(10 downto 0); 155 153 variable c_prev_top, c_prev_bot, c_prev_left, c_prev_right : std_logic_vector(10 downto 0); 156 154 variable tcx, tcy, dcx, dcy : std_logic_vector(10 downto 0); ··· 302 300 c_top := py - SIZE11; 303 301 c_bot := py + SIZE11; 304 302 305 - if c_right >= OBS_L(obs_i) and c_left <= OBS_R(obs_i) and 306 - c_bot >= OBS_T(obs_i) and c_top <= OBS_B(obs_i) then 303 + -- 1. Swept Horizontal Overlap 304 + if vx(9) = '0' then -- moving right 305 + x_overlap := (c_right >= OBS_L(obs_i)) and (c_prev_left <= OBS_R(obs_i)); 306 + else -- moving left 307 + x_overlap := (c_prev_right >= OBS_L(obs_i)) and (c_left <= OBS_R(obs_i)); 308 + end if; 309 + 310 + -- 2. Swept Vertical Overlap 311 + if vy(9) = '0' then -- moving down (gravity is positive) 312 + y_overlap := (c_bot >= OBS_T(obs_i)) and (c_prev_top <= OBS_B(obs_i)); 313 + else -- moving up 314 + y_overlap := (c_prev_bot >= OBS_T(obs_i)) and (c_top <= OBS_B(obs_i)); 315 + end if; 316 + 317 + -- 3. Check collision using the swept bounds 318 + if x_overlap and y_overlap then 307 319 308 320 if c_prev_bot <= OBS_T(obs_i) then 309 321 -- Entered from top → land on surface