Skip to content

Commit 03a6555

Browse files
author
Roo Code
committed
reporting 95 percent complete
1 parent c68f9f8 commit 03a6555

File tree

10 files changed

+3921
-3343
lines changed

10 files changed

+3921
-3343
lines changed

client/src/features/physics/components/PhysicsEngineControls.tsx

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,74 @@ export function PhysicsEngineControls() {
683683
</div>
684684
</CardContent>
685685
</Card>
686+
687+
{/* SSSP Integration Section */}
688+
<Card>
689+
<CardHeader>
690+
<CardTitle className="flex items-center gap-2">
691+
<GitBranch className="h-5 w-5" />
692+
SSSP Path Integration
693+
</CardTitle>
694+
<CardDescription>
695+
Single-Source Shortest Path influence on spring forces
696+
</CardDescription>
697+
</CardHeader>
698+
<CardContent className="space-y-4">
699+
<div className="flex items-center justify-between">
700+
<div className="space-y-1">
701+
<Label htmlFor="useSsspDistances">Enable SSSP Integration</Label>
702+
<p className="text-xs text-muted-foreground">
703+
Modulate spring forces based on shortest path distances
704+
</p>
705+
</div>
706+
<Switch
707+
id="useSsspDistances"
708+
checked={physicsSettings?.useSsspDistances || false}
709+
onCheckedChange={(checked) => updatePhysics({ useSsspDistances: checked })}
710+
/>
711+
</div>
712+
713+
{physicsSettings?.useSsspDistances && (
714+
<div className="space-y-2">
715+
<div className="flex justify-between items-center">
716+
<TooltipProvider>
717+
<Tooltip>
718+
<TooltipTrigger asChild>
719+
<Label htmlFor="ssspAlpha" className="flex items-center gap-1">
720+
SSSP Influence
721+
<Info className="h-3 w-3 text-muted-foreground" />
722+
</Label>
723+
</TooltipTrigger>
724+
<TooltipContent>
725+
<p>Weight factor for SSSP distances (0.0 = no effect, 1.0 = full effect)</p>
726+
</TooltipContent>
727+
</Tooltip>
728+
</TooltipProvider>
729+
<span className="text-sm text-muted-foreground">
730+
{(physicsSettings?.ssspAlpha || 0.5).toFixed(2)}
731+
</span>
732+
</div>
733+
<Slider
734+
id="ssspAlpha"
735+
min={0}
736+
max={1}
737+
step={0.01}
738+
value={[physicsSettings?.ssspAlpha || 0.5]}
739+
onValueChange={([v]) => updatePhysics({ ssspAlpha: v })}
740+
/>
741+
742+
<div className="mt-3 p-3 bg-muted/50 rounded-md">
743+
<p className="text-xs text-muted-foreground">
744+
SSSP integration adjusts rest length of springs based on shortest path distance between nodes:
745+
</p>
746+
<code className="text-xs mt-1 block">
747+
ideal_length = rest_length + alpha * |d[u] - d[v]|
748+
</code>
749+
</div>
750+
</div>
751+
)}
752+
</CardContent>
753+
</Card>
686754
</TabsContent>
687755

688756
{/* Constraints Tab */}

client/src/types/binaryProtocol.ts

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,27 @@ export interface BinaryNodeData {
1414
nodeId: number;
1515
position: Vec3;
1616
velocity: Vec3;
17-
// SSSP data removed - now fetched via REST API when needed
18-
// This reduces binary message size from 34 to 26 bytes per node
17+
ssspDistance: number; // Shortest path distance from source
18+
ssspParent: number; // Parent node for path reconstruction
1919
}
2020

2121
/**
22-
* Node binary format (Optimized):
23-
* - Node ID: 4 bytes (uint32) - full node ID without flags
22+
* Node binary format (Updated to match server):
23+
* - Node ID: 2 bytes (uint16) - optimized size
2424
* - Position: 12 bytes (3 float32 values)
2525
* - Velocity: 12 bytes (3 float32 values)
26-
* Total: 28 bytes per node (reduced from 34)
26+
* - SSSP Distance: 4 bytes (float32)
27+
* - SSSP Parent: 4 bytes (int32)
28+
* Total: 34 bytes per node
2729
*
28-
* SSSP and other analytics data are fetched via REST API when needed
30+
* SSSP data is included for real-time path visualization
2931
*/
30-
export const BINARY_NODE_SIZE = 28;
32+
export const BINARY_NODE_SIZE = 34;
3133
export const BINARY_NODE_ID_OFFSET = 0;
32-
export const BINARY_POSITION_OFFSET = 4;
33-
export const BINARY_VELOCITY_OFFSET = 16;
34-
// SSSP offsets removed - data no longer in binary protocol
34+
export const BINARY_POSITION_OFFSET = 2; // After uint16 node ID
35+
export const BINARY_VELOCITY_OFFSET = 14; // After position (2 + 12)
36+
export const BINARY_SSSP_DISTANCE_OFFSET = 26; // After velocity (14 + 12)
37+
export const BINARY_SSSP_PARENT_OFFSET = 30; // After distance (26 + 4)
3538

3639
// Node type flag constants (must match server) - adjusted for u16
3740
export const AGENT_NODE_FLAG = 0x8000; // Bit 15 indicates agent node
@@ -107,24 +110,28 @@ export function parseBinaryNodeData(buffer: ArrayBuffer): BinaryNodeData[] {
107110
break;
108111
}
109112

110-
// Read node ID (uint32, 4 bytes) - no flags needed anymore
111-
const nodeId = view.getUint32(offset + BINARY_NODE_ID_OFFSET, true);
113+
// Read node ID (uint16, 2 bytes)
114+
const nodeId = view.getUint16(offset + BINARY_NODE_ID_OFFSET, true);
112115

113116
// Read position (3 float32 values, 12 bytes)
114117
const position: Vec3 = {
115118
x: view.getFloat32(offset + BINARY_POSITION_OFFSET, true),
116119
y: view.getFloat32(offset + BINARY_POSITION_OFFSET + 4, true),
117120
z: view.getFloat32(offset + BINARY_POSITION_OFFSET + 8, true)
118121
};
119-
122+
120123
// Read velocity (3 float32 values, 12 bytes)
121124
const velocity: Vec3 = {
122125
x: view.getFloat32(offset + BINARY_VELOCITY_OFFSET, true),
123126
y: view.getFloat32(offset + BINARY_VELOCITY_OFFSET + 4, true),
124127
z: view.getFloat32(offset + BINARY_VELOCITY_OFFSET + 8, true)
125128
};
126129

127-
// SSSP data removed - fetched via REST API when needed
130+
// Read SSSP distance (float32, 4 bytes)
131+
const ssspDistance = view.getFloat32(offset + BINARY_SSSP_DISTANCE_OFFSET, true);
132+
133+
// Read SSSP parent (int32, 4 bytes)
134+
const ssspParent = view.getInt32(offset + BINARY_SSSP_PARENT_OFFSET, true);
128135

129136
// Basic validation to detect corrupted data
130137
const isValid =
@@ -136,7 +143,7 @@ export function parseBinaryNodeData(buffer: ArrayBuffer): BinaryNodeData[] {
136143
!isNaN(velocity.z) && isFinite(velocity.z);
137144

138145
if (isValid) {
139-
nodes.push({ nodeId, position, velocity });
146+
nodes.push({ nodeId, position, velocity, ssspDistance, ssspParent });
140147
} else {
141148
console.warn(`Skipping corrupted node data at offset ${offset} (nodeId: ${nodeId})`);
142149
}
@@ -158,15 +165,15 @@ export function createBinaryNodeData(nodes: BinaryNodeData[]): ArrayBuffer {
158165

159166
nodes.forEach((node, i) => {
160167
const offset = i * BINARY_NODE_SIZE;
161-
168+
162169
// Write node ID (uint16, 2 bytes)
163170
view.setUint16(offset + BINARY_NODE_ID_OFFSET, node.nodeId, true);
164-
171+
165172
// Write position (3 float32 values, 12 bytes)
166173
view.setFloat32(offset + BINARY_POSITION_OFFSET, node.position.x, true);
167174
view.setFloat32(offset + BINARY_POSITION_OFFSET + 4, node.position.y, true);
168175
view.setFloat32(offset + BINARY_POSITION_OFFSET + 8, node.position.z, true);
169-
176+
170177
// Write velocity (3 float32 values, 12 bytes)
171178
view.setFloat32(offset + BINARY_VELOCITY_OFFSET, node.velocity.x, true);
172179
view.setFloat32(offset + BINARY_VELOCITY_OFFSET + 4, node.velocity.y, true);

0 commit comments

Comments
 (0)