|
|
|
@ -116,17 +116,26 @@ public partial class Grid : Area3D |
|
|
|
|
return _material; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
BoxShape3D _shape; |
|
|
|
|
ConvexPolygonShape3D _shape; |
|
|
|
|
void UpdateCollisionShape() |
|
|
|
|
{ |
|
|
|
|
if (Engine.IsEditorHint()) return; |
|
|
|
|
|
|
|
|
|
if (_shape == null) { |
|
|
|
|
_shape = new BoxShape3D(); |
|
|
|
|
_shape = new ConvexPolygonShape3D(); |
|
|
|
|
AddChild(new CollisionShape3D { Shape = _shape }, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_shape.Size = new(GridSize.X * StepSize, 0.001f, GridSize.Y * StepSize); |
|
|
|
|
const float Offset = 0.001f; |
|
|
|
|
var x = GridSize.X * StepSize / 2; |
|
|
|
|
var y = GridSize.Y * StepSize / 2; |
|
|
|
|
|
|
|
|
|
_shape.Points = [ |
|
|
|
|
new(-x, Offset, -y), |
|
|
|
|
new( x, Offset, -y), |
|
|
|
|
new( x, Offset, y), |
|
|
|
|
new(-x, Offset, y), |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ImmediateMesh _mesh; |
|
|
|
|