106 lines
2.4 KiB
Odin
106 lines
2.4 KiB
Odin
package ion
|
|
import "core:slice"
|
|
import "core:fmt"
|
|
import im "shared:odin-imgui"
|
|
import b2 "vendor:box2d"
|
|
|
|
/*
|
|
This library will only account for box2d's entities editing
|
|
|
|
It only deals with one world_id, which means typically one level
|
|
|
|
All the interface follows a pattern
|
|
i.e. It takes interface_state pointer and returns a boolean indicating weather the world needs to be reloaded
|
|
|
|
*/
|
|
|
|
EditMode :: enum
|
|
{
|
|
ENTITY,
|
|
VERTICES,
|
|
OVERVIEW,
|
|
CHAIN,
|
|
JOINT,
|
|
}
|
|
|
|
interface_state :: struct
|
|
{
|
|
entity_defs : [dynamic]^engine_entity_def,
|
|
entities : [dynamic]^engine_entity,
|
|
selected_entity : ^i32,
|
|
world : ^engine_world,
|
|
state : ^engine_state,
|
|
|
|
vertex_index : ^i32,
|
|
chain_index : ^i32,
|
|
|
|
edit_mode : EditMode,
|
|
|
|
curr_joint_index : i32,
|
|
curr_joint_type : b2.JointType,
|
|
|
|
curr_static_index : static_index_global,
|
|
}
|
|
|
|
interface_draw_options :: proc(state: ^engine_state) {
|
|
debug_draw := &state.draw.debug_draw
|
|
|
|
im.SliderFloat("Zoom", &state.draw.cam.zoom, 0, 100)
|
|
im.Checkbox("Shapes", &debug_draw.drawShapes)
|
|
im.Checkbox("Joints", &debug_draw.drawJoints)
|
|
im.Checkbox("Joint Extras", &debug_draw.drawJointExtras)
|
|
im.Checkbox("Bounds", &debug_draw.drawBounds)
|
|
im.Checkbox("Contact Points", &debug_draw.drawContacts)
|
|
im.Checkbox("Contact Normals", &debug_draw.drawContactNormals)
|
|
im.Checkbox("Contact Inpulses", &debug_draw.drawContactImpulses)
|
|
im.Checkbox("Contact Features", &debug_draw.drawContactFeatures)
|
|
im.Checkbox("Friction Inpulses", &debug_draw.drawFrictionImpulses)
|
|
im.Checkbox("Mass ", &debug_draw.drawMass)
|
|
im.Checkbox("Body Names", &debug_draw.drawBodyNames)
|
|
im.Checkbox("Graph Colors", &debug_draw.drawGraphColors)
|
|
im.Checkbox("Islands ", &debug_draw.drawIslands)
|
|
im.SliderFloat("Rotation", &state.draw.cam.rotation, 0, 360)
|
|
}
|
|
|
|
|
|
interface_all :: proc(interface: ^interface_state) -> bool
|
|
{
|
|
ret := false
|
|
if im.Begin("Box2d interface")
|
|
{
|
|
if im.BeginTabBar("Tabs")
|
|
{
|
|
|
|
if im.BeginTabItem("Entity", nil, {.Leading})
|
|
{
|
|
if interface_entity(interface) do ret = true
|
|
im.EndTabItem()
|
|
}
|
|
|
|
|
|
if im.BeginTabItem("Joints", nil, {})
|
|
{
|
|
if interface_joints(interface) do ret = true
|
|
im.EndTabItem()
|
|
}
|
|
|
|
if im.BeginTabItem("Draw Options", nil, {})
|
|
{
|
|
interface_draw_options(interface.state)
|
|
im.EndTabItem()
|
|
}
|
|
|
|
im.EndTabBar()
|
|
}
|
|
}
|
|
im.End()
|
|
return ret
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|