- Created ROADMAP.md outlining core features, implementation phases, and detailed breakdown for the Stickman Sandbox Builder project. - Introduced plans for dynamic vector props with `PropBlock` specification, including reusable components and utility functions for prop creation. - Developed a vector terrain system plan detailing the reusable `TerrainBlock` component and associated utility functions for geometry handling. - Implemented `PhysicsTestHarness` scene for testing physics interactions with dynamic props and terrain. - Added scripts for `PropBlock`, `PropUtils`, `TerrainBlock`, and `TerrainUtils` to support dynamic prop creation and terrain management.
3.6 KiB
3.6 KiB
Specification: Dynamic Vector Props (PropBlock)
Objective: Create a reusable, dynamic physics prop framework (PropBlock) using RigidBody2D with resolution-independent vector visuals (Polygon2D, Line2D) and configurable physics material profiles (mass, friction, bounce) that interact with TerrainBlock instances.
1. Reusable PropBlock Component (RigidBody2D)
- Node Hierarchy: A root
RigidBody2Dwith three direct children:Polygon2Dfor interior visual fill,Line2Dfor crisp vector borders, and a physics collision node (CollisionPolygon2Dfor custom polygons orCollisionShape2Dwith aCircleShape2Dfor spheres). - Script Architecture:
class_name PropBlock,extends RigidBody2Dequipped with@toolmode for live editor previewing. - Exported Properties:
- Shape Parameters: Shape type selector (Polygon vs. Circle),
polygon_points(PackedVector2Array), andradius(float). - Visual Styling:
fill_color,outline_color, andoutline_widthmatching the stroke aesthetic ofTerrainBlock. - Physics Presets: A preset selector or exported
PhysicsMaterialhandle for quick material assignment (e.g., Wood Crate, Bouncy Rubber, Light Cardboard, Heavy Metal).
- Shape Parameters: Shape type selector (Polygon vs. Circle),
- Live Update Setter: A unified property setter that updates visual fill and border geometry dynamically:
- Polygons: Assigns
polygon_pointstoPolygon2DandCollisionPolygon2D(BUILD_SOLIDS), closing theLine2Doutline by appending the first vertex to the end with rounded line joints and caps. - Circles: Generates a smooth radial point loop for
Polygon2DandLine2Dwhile updating the radius of aCircleShape2Dto maintain fast, accurate spherical collision.
- Polygons: Assigns
2. PropUtils Factory & Preset Helper
- Class Setup:
class_name PropUtils,extends RefCountedproviding static utility methods for spawning dynamic props. - Primitive Generators: Helper functions to programmatically build common prop primitives (e.g.,
create_box(),create_ball(),create_plank(),create_triangle()) with default vector dimensions and color themes. - Physics Material Presets: Internal factory definitions for pre-configured
PhysicsMaterialresources:- Wood: Moderate mass, medium friction, low bounce.
- Rubber: Low mass, high friction, high restitution/bounce (
0.8+). - Metal: High mass, high friction, zero bounce.
- Point Sanitization: Any custom polygonal points passed to
PropUtilsshould run throughTerrainUtils.sanitize_points()to guarantee clockwise vertex order and strip collinear points before creating the prop. - Spawner Factory (
spawn_prop): Static function taking a target parent container, position, shape payload, and material preset to instantiate aPropBlock, set its initial velocity, and add it to the scene.
3. PhysicsTestHarness Staging Integration
- Controls & Spawning: Update
scripts/physics_test_harness.gdto bind key inputs (or mouse clicks) for spawning dynamic props directly into the test world (e.g., Press1for Wood Crate,2for Bouncy Ball,3for Heavy Plank). - Physics Verification Checklist:
- Vector Scaling & Zoom: Ensure stroke weights and line join quality on dynamic props remain crisp and visually coherent with static terrain across camera zoom levels (0.25x to 3.0x).
- Collision Accuracy: Verify dynamic props roll smoothly down angled ramps, bounce predictably off step ledges, and stack stably on flat terrain without clipping or falling through
TerrainBlockgeometry. - Rig Interaction: Confirm dynamic props collide accurately with the standing
MasterRiginstance on the ground.