Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions editor/src/editor/layout/inspector/mesh/collision.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ export class EditorMeshCollisionInspector extends Component<IEditorInspectorImpl
}

public render(): ReactNode {
// if (collisionMesh && isInstancedMesh(this.props.object)) {
// return false;
// }

return (
<EditorInspectorSectionField
title="Collisions"
Expand All @@ -68,16 +64,25 @@ export class EditorMeshCollisionInspector extends Component<IEditorInspectorImpl
/>

{this._mesh.checkCollisions && (
<div
className="flex gap-2 items-center"
onMouseMove={() => this._setTemporaryCollisionMeshVisible(true)}
onMouseLeave={() => this._setTemporaryCollisionMeshVisible(false)}
>
{this._getCollisionType(this._collisionMesh, "cube", <RxCube size={42} />)}
{this._getCollisionType(this._collisionMesh, "sphere", <ImSphere size={42} />)}
{this._getCollisionType(this._collisionMesh, "capsule", <RiCapsuleFill size={42} />)}
{this._getCollisionType(this._collisionMesh, "lod", <GiMeshNetwork size={42} />)}
</div>
<>
<EditorInspectorSwitchField
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just ot understand, what is the purpose of it?

label="Trigger Only"
object={this._mesh.metadata ??= {}}
property="isTriggerOnly"
onChange={() => this.forceUpdate()}
/>

<div
className="flex gap-2 items-center"
onMouseMove={() => this._setTemporaryCollisionMeshVisible(true)}
onMouseLeave={() => this._setTemporaryCollisionMeshVisible(false)}
>
{this._getCollisionType(this._collisionMesh, "cube", <RxCube size={42} />)}
{this._getCollisionType(this._collisionMesh, "sphere", <ImSphere size={42} />)}
{this._getCollisionType(this._collisionMesh, "capsule", <RiCapsuleFill size={42} />)}
{this._getCollisionType(this._collisionMesh, "lod", <GiMeshNetwork size={42} />)}
</div>
</>
)}
</EditorInspectorSectionField>
);
Expand Down
3 changes: 1 addition & 2 deletions editor/src/editor/layout/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ import { UniqueNumber, waitNextAnimationFrame, waitUntil } from "../../tools/too
import { isSprite, isSpriteManagerNode, isSpriteMapNode } from "../../tools/guards/sprites";
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "../../ui/shadcn/ui/dropdown-menu";
import { Popover, PopoverContent, PopoverTrigger } from "../../ui/shadcn/ui/popover";
import { isAbstractMesh, isAnyTransformNode, isCamera, isCollisionInstancedMesh, isCollisionMesh, isInstancedMesh, isLight, isMesh, isNode } from "../../tools/guards/nodes";

import { isAbstractMesh, isAnyTransformNode, isCamera, isCollisionInstancedMesh, isCollisionMesh, isLight, isNode } from "../../tools/guards/nodes";
import { EditorCamera } from "../nodes/camera";

import { SpinnerUIComponent } from "../../ui/spinner";
Expand Down
6 changes: 3 additions & 3 deletions editor/src/editor/nodes/collision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ export class CollisionMesh extends Mesh {
}

private _createCapsuleCollisionMesh(sourceMesh: AbstractMesh, boundingInfo: BoundingInfo): void {
const size = boundingInfo.boundingBox.maximum.subtract(boundingInfo.boundingSphere.minimum);
const size = boundingInfo.boundingBox.maximum.subtract(boundingInfo.boundingBox.minimum);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! I missed that part!
Replacing boundingBox by boundingSphere on both minumum and maximum did not do the trick?


const geometry = new Geometry(
Tools.RandomId(),
sourceMesh.getScene(),
CreateCapsuleVertexData({
height: Math.abs(size.y),
radius: boundingInfo.boundingSphere.radius,
height: Math.abs(size.y),
radius: Math.max(size.x, size.z) / 2,

subdivisions: 16,
tessellation: 16,
Expand Down