Refactor draw to be separate and handle ortho draw
This commit is contained in:
+89
-2
@@ -2,6 +2,7 @@ package edit2d
|
||||
|
||||
import b2 "vendor:box2d"
|
||||
import im "shared:odin-imgui"
|
||||
import mu "vendor:microui"
|
||||
import "core:slice"
|
||||
import draw "./draw"
|
||||
import "core:fmt"
|
||||
@@ -122,6 +123,92 @@ interface_edit_static_index :: proc(interface:^interface_state, def: ^engine_ent
|
||||
return false
|
||||
}
|
||||
|
||||
mu_interface_shape_def_editor :: proc(
|
||||
state : ^engine_state,
|
||||
def : ^engine_entity_def) -> bool
|
||||
{
|
||||
shape_def := &def.shape_def
|
||||
|
||||
mu.label(&state.mu_ctx, "Shape Type")
|
||||
for type in b2.ShapeType
|
||||
{
|
||||
b := def.shape_type == type
|
||||
if .CHANGE in mu.checkbox(&state.mu_ctx, fmt.tprint(type), &b) do def.shape_type = type
|
||||
}
|
||||
|
||||
switch def.shape_type
|
||||
{
|
||||
case .circleShape:{
|
||||
mu.label(&state.mu_ctx, "Radius")
|
||||
mu.slider(&state.mu_ctx, &def.radius, 0, 40)
|
||||
}
|
||||
|
||||
case .polygonShape:{
|
||||
mu.label(&state.mu_ctx, "Size")
|
||||
mu.slider(&state.mu_ctx, &def.size[0], -500, 500)
|
||||
mu.slider(&state.mu_ctx, &def.size[1], -500, 500)
|
||||
}
|
||||
|
||||
case .capsuleShape:{
|
||||
mu.label(&state.mu_ctx, "Center 1")
|
||||
mu.slider(&state.mu_ctx, &def.centers[0][0], -100, 100)
|
||||
mu.slider(&state.mu_ctx, &def.centers[0][1], -100, 100)
|
||||
mu.label(&state.mu_ctx, "Center 2")
|
||||
mu.slider(&state.mu_ctx, &def.centers[1][0], -100, 100)
|
||||
mu.slider(&state.mu_ctx, &def.centers[1][1], -100, 100)
|
||||
mu.label(&state.mu_ctx, "Radius")
|
||||
mu.slider(&state.mu_ctx, &def.radius, 0, 40)
|
||||
}
|
||||
|
||||
case .chainSegmentShape:{
|
||||
mu.checkbox(&state.mu_ctx, "Is Loop", &def.is_loop)
|
||||
}
|
||||
case .segmentShape:{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
mu.label(&state.mu_ctx, "Density")
|
||||
mu.slider(&state.mu_ctx, &def.shape_def.density, 0, 100)
|
||||
|
||||
if .SUBMIT in mu.button(&state.mu_ctx, "Flip horizontally") do flip_points(def.vertices[:], .Horizontal)
|
||||
if .SUBMIT in mu.button(&state.mu_ctx, "Flip Vertically ") do flip_points(def.vertices[:], .Vertical)
|
||||
|
||||
if .ACTIVE in mu.begin_treenode(&state.mu_ctx, "Events and contacts")
|
||||
{
|
||||
mu.checkbox(&state.mu_ctx, "Is sensor", &def.shape_def.isSensor)
|
||||
mu.checkbox(&state.mu_ctx, "Enable Sensor Events", &def.shape_def.enableSensorEvents)
|
||||
mu.checkbox(&state.mu_ctx, "Enable Contact Events", &def.shape_def.enableContactEvents)
|
||||
mu.checkbox(&state.mu_ctx, "Enable Hit Events", &def.shape_def.enableHitEvents)
|
||||
mu.checkbox(&state.mu_ctx, "Enable Presolve Events", &def.shape_def.enablePreSolveEvents)
|
||||
mu.checkbox(&state.mu_ctx, "Invoke contact Creation", &def.shape_def.invokeContactCreation)
|
||||
mu.checkbox(&state.mu_ctx, "Update body mass ", &def.shape_def.updateBodyMass)
|
||||
|
||||
mu.end_treenode(&state.mu_ctx)
|
||||
}
|
||||
|
||||
if .ACTIVE in mu.begin_treenode(&state.mu_ctx, "Material")
|
||||
{
|
||||
mu.label(&state.mu_ctx, "Friction")
|
||||
mu.slider(&state.mu_ctx, &def.shape_def.material.friction, 0, 1)
|
||||
|
||||
mu.label(&state.mu_ctx, "Restitution")
|
||||
mu.slider(&state.mu_ctx, &def.shape_def.material.restitution, 0, 1)
|
||||
|
||||
mu.label(&state.mu_ctx, "Rolling Resistance")
|
||||
mu.slider(&state.mu_ctx, &def.shape_def.material.rollingResistance, 0, 1)
|
||||
|
||||
mu.label(&state.mu_ctx, "Tangent Speed")
|
||||
mu.slider(&state.mu_ctx, &def.shape_def.material.tangentSpeed, 0, 1)
|
||||
|
||||
//if .ACTIVE in mu.begin_treenode(&state.mu_ctx, "Color")
|
||||
|
||||
mu.end_treenode(&state.mu_ctx)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
interface_shape_def_editor :: proc(def: ^engine_entity_def) -> bool
|
||||
{
|
||||
@@ -211,7 +298,6 @@ interface_shape_def_editor :: proc(def: ^engine_entity_def) -> bool
|
||||
im.Separator()
|
||||
im.TreePop()
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -238,8 +324,9 @@ interface_entity :: proc(interface: ^interface_state) -> bool
|
||||
|
||||
if im.CollapsingHeader("Shape Edit")
|
||||
{
|
||||
interface_shape_def_editor(def)
|
||||
//interface_shape_def_editor(def)
|
||||
}
|
||||
mu_interface_shape_def_editor(interface.state, def)
|
||||
|
||||
im.Separator()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user