Compose source body physics and enable tutorial static response
This commit is contained in:
1 parent
df0263b26e
commit
35a2a66606
26 files changed
+1045
-18
No files matched your search
@@ -0,0 +1,93 @@
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT/'tools/binary'))
|
||||
from body_composition_contract import can_publish, collect, phase_order
|
||||
|
||||
|
||||
class BodyCompositionContractTests(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.report = collect(ROOT.parent/'Original')
|
||||
|
||||
def test_original_body_identity_and_decisive_sites(self):
|
||||
self.assertEqual(self.report['body']['file_offset'], '0x79d20')
|
||||
sites = {site['name']: site for site in self.report['sites']}
|
||||
self.assertEqual(sites['clamp_candidate_y']['bytes'], 'd9442420d81d086a4d00')
|
||||
self.assertEqual(sites['delta_y_nonpositive_branch']['bytes'], 'f6c441753d')
|
||||
self.assertEqual(sites['root_compare_w']['file_offset'], '0x7a176')
|
||||
self.assertEqual(len(sites), 81)
|
||||
|
||||
def test_disabled_integration_still_clears_support(self):
|
||||
self.assertEqual(phase_order(integration_enabled=False),
|
||||
['read_previous_support', 'clear_current_support', 'integration_gate'])
|
||||
self.assertEqual(phase_order(support_enabled=False, integration_enabled=False),
|
||||
['read_previous_support', 'integration_gate'])
|
||||
|
||||
def test_rotation_impulse_acceleration_gravity_and_suppression_order(self):
|
||||
order = phase_order(upward=True)
|
||||
names = ('rotate', 'impulse_add', 'impulse_clear', 'acceleration_add', 'gravity_add',
|
||||
'velocity_to_delta', 'full_dispatch', 'support47b890',
|
||||
'published_speed_zero_friction', 'angular_suppression',
|
||||
'published_speed_zero_linear_suppression')
|
||||
self.assertEqual(sorted(order.index(name) for name in names), [order.index(name) for name in names])
|
||||
|
||||
def test_nonpositive_vertical_motion_is_added_after_horizontal_response(self):
|
||||
down = phase_order(upward=False)
|
||||
up = phase_order(upward=True)
|
||||
self.assertLess(down.index('horizontal_dispatch'), down.index('add_fall_y'))
|
||||
self.assertLess(down.index('add_fall_y'), down.index('compare_previous_live_root_vec4'))
|
||||
self.assertNotIn('add_fall_y', up)
|
||||
self.assertNotIn('horizontal_dispatch', up)
|
||||
|
||||
def test_collision_world_and_global_geometry_are_separate_gates(self):
|
||||
collision_off = phase_order(collision_enabled=False)
|
||||
world_off = phase_order(world_enabled=False)
|
||||
geometry_off = phase_order(geometry_enabled=False)
|
||||
self.assertNotIn('support47b890', collision_off)
|
||||
self.assertNotIn('published_speed_zero_friction', collision_off)
|
||||
self.assertIn('translate31c', collision_off)
|
||||
self.assertNotIn('translate31c', phase_order(collision_enabled=False, translation_locked=True))
|
||||
self.assertIn('support47b890', world_off)
|
||||
self.assertIn('published_speed_zero_friction', world_off)
|
||||
self.assertNotIn('reset_static_context', world_off)
|
||||
self.assertIn('reset_static_context', geometry_off)
|
||||
self.assertIn('geometry_off_support_anchor_acceleration_velocity', geometry_off)
|
||||
|
||||
def test_publication_compares_fresh_previous_and_live_root_vec4(self):
|
||||
root = (1.0, 2.0, 3.0, 1.0)
|
||||
self.assertTrue(can_publish(root, root))
|
||||
for component in range(4):
|
||||
changed = list(root)
|
||||
changed[component] += 1
|
||||
self.assertFalse(can_publish(root, changed))
|
||||
with self.assertRaises(ValueError):
|
||||
can_publish(root[:3], root[:3])
|
||||
|
||||
def test_burst_and_support_share_live_radius_and_factor(self):
|
||||
targets = {entry['slot']: entry['target'] for entry in self.report['tables']}
|
||||
self.assertEqual(targets['0x110'], '0x471240')
|
||||
self.assertEqual(targets['0x260'], '0x471b30')
|
||||
self.assertEqual(targets['0x264'], '0x471b40')
|
||||
self.assertEqual(targets['0x250'], '0x471af0')
|
||||
self.assertEqual(targets['0x254'], '0x471b00')
|
||||
self.assertAlmostEqual(self.report['constants']['factor'], 1.265, places=6)
|
||||
|
||||
def test_init_restores_authored_speed_separately_from_controller_publication(self):
|
||||
targets = {entry['slot']: entry['target'] for entry in self.report['tables']}
|
||||
self.assertEqual(targets['0x114'], '0x471260')
|
||||
self.assertEqual(targets['0x118'], '0x471270')
|
||||
self.assertEqual(targets['0x268'], '0x471b50')
|
||||
self.assertEqual(targets['0x26c'], '0x471b60')
|
||||
sites = {site['name']: site for site in self.report['sites']}
|
||||
self.assertEqual(sites['init_authored_speed114']['file_offset'], '0x706cf')
|
||||
self.assertEqual(sites['init_publish_speed26c']['file_offset'], '0x706db')
|
||||
self.assertIn('894138', sites['authored_speed_setter118_to_live26c']['bytes'])
|
||||
self.assertNotIn('894138', sites['published_speed_setter26c']['bytes'])
|
||||
self.assertEqual(self.report['constants']['constructor_authored_speed'], 0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user