Skip to content

Implement closest points between bodies via GJK #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
34 changes: 17 additions & 17 deletions sandbox/src/Main.elm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Main exposing (main)

import Array exposing (Array)
import Body exposing (Body, Shape(..))
import Body exposing (Body, Shape(..))
import Browser
import Browser.Events
import CSOPoint exposing (CSOPoint)
Expand All @@ -14,8 +14,6 @@ import ConfigForm.Options
import ConfigForm.Types exposing (Field)
import ConvexHull
import Draggable
import Gjk
import Epa exposing (Polytope(..))
import Element
exposing
( alignTop
Expand All @@ -37,7 +35,9 @@ import Element.Background as Background
import Element.Border as Border
import Element.Font as Font
import Element.Input as Input
import Epa exposing (Polytope(..))
import Fps
import Gjk
import Hierarchy
import Html exposing (Html)
import Html.Attributes
Expand Down Expand Up @@ -481,21 +481,8 @@ view model =
]
model.bodies
:: listIf model.config.showSupportPoints (supportPoints mousePosition model.bodies)
++ listIf model.config.showMinkowskiDifference (renderMinkowskiDifference <| minkowskiDifference model.config.pointsPerCircle b1 b2)
++ listIf model.config.showGjkSimplex [ renderSimplex b1.transform res.simplex ]
++ listIf model.config.showMinkowskiDifference
(minkowskiDifference model.config.pointsPerCircle b1 b2
|> (\points ->
[ Render.polygon
[ Svg.stroke "lightgreen"
, Svg.fill "none"
, Svg.strokeWidth "2"
]
points
, Render.group [ Svg.fill "lightgreen" ]
(List.map (Render.point []) points)
]
)
)
++ Misc.listIfLazy (model.config.showEpaPolytope && res.colliding)
(\_ ->
case
Expand Down Expand Up @@ -930,3 +917,16 @@ getCircle b =

_ ->
Nothing


renderMinkowskiDifference : List Vec2 -> List (Renderable msg)
renderMinkowskiDifference points =
[ Render.polygon
[ Svg.stroke "lightgreen"
, Svg.fill "none"
, Svg.strokeWidth "2"
]
points
, Render.group [ Svg.fill "lightgreen" ]
(List.map (Render.point []) points)
]