Skip to content

Commit

Permalink
Basic Passive Constraints (#970)
Browse files Browse the repository at this point in the history
  • Loading branch information
HunterBarclay authored Mar 23, 2024
2 parents a4f9195 + 261c82d commit e4e1e00
Show file tree
Hide file tree
Showing 8 changed files with 320 additions and 28 deletions.
Binary file added fission/public/test_mira/HingeTestFission_v1.mira
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions fission/src/Synthesis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ import World from './systems/World.ts';

const DEFAULT_MIRA_PATH = 'test_mira/Team_2471_(2018)_v7.mira';
// const DEFAULT_MIRA_PATH = 'test_mira/Dozer_v2.mira';
// const DEFAULT_MIRA_PATH = 'test_mira/PhysicsSpikeTest_v1.mira';
// const DEFAULT_MIRA_PATH = 'test_mira/SliderTestFission_v2.mira';
// const DEFAULT_MIRA_PATH = 'test_mira/HingeTestFission_v1.mira';

function Synthesis() {
const { openModal, closeModal, getActiveModalElement } =
Expand Down
7 changes: 4 additions & 3 deletions fission/src/mirabuf/MirabufParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export enum ParseErrorSeverity {
JustAWarning = 2
}

const GROUNDED_JOINT_ID = 'grounded';
export const GROUNDED_JOINT_ID = 'grounded';
export const GAMEPIECE_SUFFIX = '_gp';

export type ParseError = [severity: ParseErrorSeverity, message: string];

Expand Down Expand Up @@ -95,7 +96,7 @@ class MirabufParser {
if (gamepieceDefinitions.has(inst.partDefinitionReference!)) {
const instNode = this.BinarySearchDesignTree(inst.info!.GUID!);
if (instNode) {
const gpRn = this.NewRigidNode('gp');
const gpRn = this.NewRigidNode(GAMEPIECE_SUFFIX);
this.MovePartToRigidNode(instNode!.value!, gpRn);
instNode.children && traverseTree(instNode.children, x => this.MovePartToRigidNode(x.value!, gpRn));
} else {
Expand Down Expand Up @@ -155,7 +156,7 @@ class MirabufParser {
}

private NewRigidNode(suffix?: string): RigidNode {
const node = new RigidNode((this._nodeNameCounter++).toString() + (suffix ? `_${suffix}` : ''));
const node = new RigidNode(`${this._nodeNameCounter++}${suffix ? suffix : ''}`);
this._rigidNodes.push(node);
return node;
}
Expand Down
11 changes: 10 additions & 1 deletion fission/src/mirabuf/MirabufSceneObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Jolt from '@barclah/jolt-physics';
import { JoltMat44_ThreeMatrix4 } from "@/util/TypeConversions";
import * as THREE from 'three';
import JOLT from "@/util/loading/JoltSyncLoader";
import { LayerReserve } from "@/systems/physics/PhysicsSystem";

const DEBUG_BODIES = true;

Expand All @@ -21,12 +22,19 @@ class MirabufSceneObject extends SceneObject {
private _mirabufInstance: MirabufInstance;
private _bodies: Map<string, Jolt.BodyID>;
private _debugBodies: Map<string, RnDebugMeshes> | null;
private _physicsLayerReserve: LayerReserve | undefined = undefined;

public constructor(mirabufInstance: MirabufInstance) {
super();

this._mirabufInstance = mirabufInstance;
this._bodies = World.PhysicsSystem.CreateBodiesFromParser(mirabufInstance.parser);

if (this._mirabufInstance.parser.assembly.dynamic) {
this._physicsLayerReserve = new LayerReserve();
}
this._bodies = World.PhysicsSystem.CreateBodiesFromParser(mirabufInstance.parser, this._physicsLayerReserve);
World.PhysicsSystem.CreateJointsFromParser(mirabufInstance.parser, this._bodies);

this._debugBodies = null;
}

Expand Down Expand Up @@ -91,6 +99,7 @@ class MirabufSceneObject extends SceneObject {
(x.comMesh.material as THREE.Material).dispose();
});
this._debugBodies?.clear();
this._physicsLayerReserve?.Release();
}

private CreateMeshForShape(shape: Jolt.Shape): THREE.Mesh {
Expand Down
Loading

0 comments on commit e4e1e00

Please sign in to comment.