Refator
This commit is contained in:
+220
@@ -0,0 +1,220 @@
|
|||||||
|
package edit2d
|
||||||
|
|
||||||
|
import e2_draw "./draw"
|
||||||
|
import b2 "vendor:box2d"
|
||||||
|
import "base:runtime"
|
||||||
|
|
||||||
|
/*
|
||||||
|
This is the integration between box2d and engine's renderer
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Put the functions to the box2d debug_draw */
|
||||||
|
|
||||||
|
|
||||||
|
make_rgba :: proc(color : b2.HexColor, alpha : f32) -> e2_draw.RGBA8 {
|
||||||
|
c := i32(color)
|
||||||
|
return {
|
||||||
|
u8((c >> 16) & 0xFF),
|
||||||
|
u8((c >> 8) & 0xFF),
|
||||||
|
u8(c & 0xFF),
|
||||||
|
u8(0xFF * alpha),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
make_hex_color :: proc(rgba: e2_draw.RGBA8) -> b2.HexColor {
|
||||||
|
return b2.HexColor((u32(rgba.r) << 16) | (u32(rgba.g) << 8) | u32(rgba.b))
|
||||||
|
}
|
||||||
|
DrawCircleFcn :: proc "c" (
|
||||||
|
center : [2]f32,
|
||||||
|
radius : f32,
|
||||||
|
color : b2.HexColor,
|
||||||
|
ctx : rawptr,
|
||||||
|
) {
|
||||||
|
context = runtime.default_context()
|
||||||
|
draw := cast(^e2_draw.Draw)ctx
|
||||||
|
rgba := make_rgba(color, 1.0)
|
||||||
|
e2_draw.circle_add(&draw.circles, center, radius, rgba)
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawSolidCircleFcn :: proc "c" (
|
||||||
|
transform : b2.Transform,
|
||||||
|
radius : f32,
|
||||||
|
color : b2.HexColor,
|
||||||
|
ctx : rawptr,
|
||||||
|
) {
|
||||||
|
|
||||||
|
context = runtime.default_context()
|
||||||
|
draw := cast(^e2_draw.Draw)ctx
|
||||||
|
|
||||||
|
transform := transform
|
||||||
|
transform.p = b2.TransformPoint(transform, {0, 0})
|
||||||
|
t := transmute(e2_draw.Transform)transform
|
||||||
|
|
||||||
|
rgba := make_rgba(color, 1.0)
|
||||||
|
|
||||||
|
e2_draw.DrawSolidCircle(
|
||||||
|
&draw.solid_circles,
|
||||||
|
t,
|
||||||
|
{0, 0},
|
||||||
|
radius,
|
||||||
|
rgba,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawSolidCapsuleFcn :: proc "c" (
|
||||||
|
p1, p2 : [2]f32,
|
||||||
|
radius : f32,
|
||||||
|
color : b2.HexColor,
|
||||||
|
ctx : rawptr,
|
||||||
|
) {
|
||||||
|
context = runtime.default_context()
|
||||||
|
draw := cast(^e2_draw.Draw)ctx
|
||||||
|
rgba := make_rgba(color, 1.0)
|
||||||
|
e2_draw.solid_capsules_add(&draw.solid_capsules, p1, p2, radius, rgba)
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawSegmentFcn :: proc "c" (
|
||||||
|
p1, p2 : [2]f32,
|
||||||
|
color : b2.HexColor,
|
||||||
|
ctx : rawptr,
|
||||||
|
) {
|
||||||
|
context = runtime.default_context()
|
||||||
|
draw := cast(^e2_draw.Draw)ctx
|
||||||
|
|
||||||
|
rgba := make_rgba(color, 1.0)
|
||||||
|
e2_draw.lines_add(&draw.lines, p1, p2, rgba)
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawTransform :: proc "c" (lines : ^e2_draw.Lines, transform : b2.Transform) {
|
||||||
|
context = runtime.default_context()
|
||||||
|
k_axis_scale : f32 = 0.2
|
||||||
|
p1 := transform.p
|
||||||
|
rgba_red := make_rgba(b2.HexColor.Red, 1.0)
|
||||||
|
rgba_green := make_rgba(b2.HexColor.Green, 1.0)
|
||||||
|
|
||||||
|
p2 := p1 + k_axis_scale * b2.Rot_GetXAxis(transform.q)
|
||||||
|
e2_draw.lines_add(lines, p1, p2, rgba_red)
|
||||||
|
|
||||||
|
p2 = p1 + k_axis_scale * b2.Rot_GetYAxis(transform.q)
|
||||||
|
e2_draw.lines_add(lines, p1, p2, rgba_green)
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawTransformFcn :: proc "c" (transform : b2.Transform, ctx : rawptr) {
|
||||||
|
context = runtime.default_context()
|
||||||
|
draw := cast(^e2_draw.Draw)ctx
|
||||||
|
DrawTransform(&draw.lines, transform)
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawSolidPolygonFcn :: proc "c" (
|
||||||
|
transform : b2.Transform,
|
||||||
|
vertices : [^][2]f32,
|
||||||
|
vertexCount : i32,
|
||||||
|
radius : f32,
|
||||||
|
color : b2.HexColor,
|
||||||
|
ctx : rawptr,
|
||||||
|
) {
|
||||||
|
|
||||||
|
context = runtime.default_context()
|
||||||
|
t := transmute(e2_draw.Transform)transform
|
||||||
|
|
||||||
|
draw := cast(^e2_draw.Draw)ctx
|
||||||
|
|
||||||
|
rgba := make_rgba(color, 1.0)
|
||||||
|
|
||||||
|
e2_draw.solid_polygon_add(
|
||||||
|
&draw.polygons,
|
||||||
|
t,
|
||||||
|
vertices,
|
||||||
|
vertexCount,
|
||||||
|
radius,
|
||||||
|
rgba,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DrawPolygonFcn :: proc "c" (vertices : [^][2]f32, vertexCount : i32, color : b2.HexColor, ctx : rawptr)
|
||||||
|
{
|
||||||
|
context = runtime.default_context()
|
||||||
|
draw := cast(^e2_draw.Draw)ctx
|
||||||
|
|
||||||
|
rgba := make_rgba(color, 1.0)
|
||||||
|
|
||||||
|
p1 := vertices[vertexCount - 1]
|
||||||
|
for i in 0 ..< vertexCount
|
||||||
|
{
|
||||||
|
p2 := vertices[i]
|
||||||
|
e2_draw.lines_add(&draw.lines, p1, vertices[i], rgba)
|
||||||
|
p1 = p2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawStringFcn :: proc "c" (
|
||||||
|
p : [2]f32,
|
||||||
|
s : cstring,
|
||||||
|
color : b2.HexColor,
|
||||||
|
ctx : rawptr,
|
||||||
|
) {
|
||||||
|
context = runtime.default_context()
|
||||||
|
draw := cast(^e2_draw.Draw)ctx
|
||||||
|
e2_draw.DrawStringVec(draw, p, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawPointFcn :: proc "c" (
|
||||||
|
p : [2]f32,
|
||||||
|
size : f32,
|
||||||
|
color : b2.HexColor,
|
||||||
|
ctx : rawptr,
|
||||||
|
) {
|
||||||
|
context = runtime.default_context()
|
||||||
|
draw :=cast(^e2_draw.Draw)ctx
|
||||||
|
|
||||||
|
rgba := make_rgba(color, 1.0)
|
||||||
|
|
||||||
|
e2_draw.points_add(&draw.points, p, size, rgba)
|
||||||
|
}
|
||||||
|
|
||||||
|
//After initilizing draw
|
||||||
|
draw_configure_box2d :: proc(state: ^engine_state)
|
||||||
|
{
|
||||||
|
|
||||||
|
debug_draw := &state.debug_draw
|
||||||
|
bounds : b2.AABB = {{-max(f32), -max(f32)}, {max(f32), max(f32)}}
|
||||||
|
|
||||||
|
debug_draw.DrawPolygonFcn = DrawPolygonFcn
|
||||||
|
debug_draw.DrawSolidPolygonFcn = DrawSolidPolygonFcn
|
||||||
|
debug_draw.DrawCircleFcn = DrawCircleFcn
|
||||||
|
debug_draw.DrawSolidCircleFcn = DrawSolidCircleFcn
|
||||||
|
debug_draw.DrawSolidCapsuleFcn = DrawSolidCapsuleFcn
|
||||||
|
debug_draw.DrawSegmentFcn = DrawSegmentFcn
|
||||||
|
debug_draw.DrawTransformFcn = DrawTransformFcn
|
||||||
|
debug_draw.DrawPointFcn = DrawPointFcn
|
||||||
|
debug_draw.DrawStringFcn = DrawStringFcn
|
||||||
|
debug_draw.drawingBounds = bounds
|
||||||
|
debug_draw.useDrawingBounds = false
|
||||||
|
debug_draw.drawShapes = true
|
||||||
|
debug_draw.drawJoints = true
|
||||||
|
debug_draw.drawJointExtras = false
|
||||||
|
debug_draw.drawBounds = false
|
||||||
|
debug_draw.drawMass = true
|
||||||
|
debug_draw.drawContacts = false
|
||||||
|
debug_draw.drawGraphColors = false
|
||||||
|
debug_draw.drawContactNormals = false
|
||||||
|
debug_draw.drawContactImpulses = false
|
||||||
|
debug_draw.drawContactFeatures = false
|
||||||
|
debug_draw.drawFrictionImpulses = false
|
||||||
|
debug_draw.drawIslands = false
|
||||||
|
debug_draw.userContext = rawptr(&state.draw)
|
||||||
|
state.draw.drawCounters = true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+68
-287
@@ -4,10 +4,9 @@ import e2_glyph "shared:Edit2D/glyph"
|
|||||||
import "core:strings"
|
import "core:strings"
|
||||||
import "base:runtime"
|
import "base:runtime"
|
||||||
import "core:fmt"
|
import "core:fmt"
|
||||||
|
import "core:math"
|
||||||
import "core:math/linalg"
|
import "core:math/linalg"
|
||||||
import gl "vendor:OpenGL"
|
import gl "vendor:OpenGL"
|
||||||
import b2 "vendor:box2d"
|
|
||||||
|
|
||||||
|
|
||||||
CameraType :: enum
|
CameraType :: enum
|
||||||
{
|
{
|
||||||
@@ -35,20 +34,12 @@ Rot :: struct
|
|||||||
|
|
||||||
Transform :: struct
|
Transform :: struct
|
||||||
{
|
{
|
||||||
p: Vec2,
|
p: [2]f32,
|
||||||
q: Rot,
|
q: Rot,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
make_rgba :: proc(color : b2.HexColor, alpha : f32) -> RGBA8 {
|
|
||||||
c := i32(color)
|
|
||||||
return {
|
|
||||||
u8((c >> 16) & 0xFF),
|
|
||||||
u8((c >> 8) & 0xFF),
|
|
||||||
u8(c & 0xFF),
|
|
||||||
u8(0xFF * alpha),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
make_rgba_i32 :: proc(color : i32, alpha : f32) -> RGBA8 {
|
make_rgba_i32 :: proc(color : i32, alpha : f32) -> RGBA8 {
|
||||||
c := i32(color)
|
c := i32(color)
|
||||||
@@ -60,10 +51,6 @@ make_rgba_i32 :: proc(color : i32, alpha : f32) -> RGBA8 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
make_hex_color :: proc(rgba: RGBA8) -> b2.HexColor {
|
|
||||||
return b2.HexColor((u32(rgba.r) << 16) | (u32(rgba.g) << 8) | u32(rgba.b))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
camera_reset_view :: proc(camera : ^Camera) {
|
camera_reset_view :: proc(camera : ^Camera) {
|
||||||
camera.center = {0, 0}
|
camera.center = {0, 0}
|
||||||
@@ -231,12 +218,14 @@ camera_build_project_matrix :: proc(
|
|||||||
return m * mat_rot
|
return m * mat_rot
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
camera_get_view_bounds :: proc(cam : ^Camera) -> b2.AABB {
|
camera_get_view_bounds :: proc(cam : ^Camera) -> b2.AABB {
|
||||||
return b2.AABB {
|
return b2.AABB {
|
||||||
lowerBound = camera_convert_screen_to_world(cam, [2]f32{0, f32(cam.height)}),
|
lowerBound = camera_convert_screen_to_world(cam, [2]f32{0, f32(cam.height)}),
|
||||||
upperBound = camera_convert_screen_to_world(cam, [2]f32{f32(cam.width), 0}),
|
upperBound = camera_convert_screen_to_world(cam, [2]f32{f32(cam.width), 0}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
Background :: struct {
|
Background :: struct {
|
||||||
@@ -430,8 +419,7 @@ points_destroy :: proc(point : ^Point) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
points_add :: proc(point : ^Point, v : [2]f32, size : f32, c : b2.HexColor) {
|
points_add :: proc(point : ^Point, v : [2]f32, size : f32, rgba : RGBA8) {
|
||||||
rgba := make_rgba(c, 1.0)
|
|
||||||
append(&point.points, PointData{v, size, rgba})
|
append(&point.points, PointData{v, size, rgba})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -458,7 +446,7 @@ points_flush :: proc(point : ^Point, cam : ^Camera) {
|
|||||||
|
|
||||||
gl.BufferSubData(
|
gl.BufferSubData(
|
||||||
gl.ARRAY_BUFFER, 0, int(batch_count * size_of(PointData)), &point.points[base])
|
gl.ARRAY_BUFFER, 0, int(batch_count * size_of(PointData)), &point.points[base])
|
||||||
|
|
||||||
gl.DrawArrays(gl.POINTS, 0, batch_count)
|
gl.DrawArrays(gl.POINTS, 0, batch_count)
|
||||||
|
|
||||||
check_opengl()
|
check_opengl()
|
||||||
@@ -573,8 +561,7 @@ lines_destroy :: proc(line : ^Lines) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lines_add :: proc(line : ^Lines, p1, p2 : [2]f32, c : b2.HexColor) {
|
lines_add :: proc(line : ^Lines, p1, p2 : [2]f32, rgba : RGBA8) {
|
||||||
rgba := make_rgba(c, 1.0)
|
|
||||||
append(&line.points, VertexData{p1, rgba})
|
append(&line.points, VertexData{p1, rgba})
|
||||||
append(&line.points, VertexData{p2, rgba})
|
append(&line.points, VertexData{p2, rgba})
|
||||||
}
|
}
|
||||||
@@ -747,9 +734,9 @@ circle_add :: proc(
|
|||||||
circle : ^Circles,
|
circle : ^Circles,
|
||||||
center : [2]f32,
|
center : [2]f32,
|
||||||
radius : f32,
|
radius : f32,
|
||||||
color : b2.HexColor,
|
rgba : RGBA8,
|
||||||
) {
|
)
|
||||||
rgba := make_rgba(color, 1.0)
|
{
|
||||||
append(&circle.circles, CircleData{center, radius, rgba})
|
append(&circle.circles, CircleData{center, radius, rgba})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1098,11 +1085,11 @@ solid_capsules_add :: proc(
|
|||||||
capsule : ^SolidCapsules,
|
capsule : ^SolidCapsules,
|
||||||
p1, p2 : [2]f32,
|
p1, p2 : [2]f32,
|
||||||
radius : f32,
|
radius : f32,
|
||||||
c : b2.HexColor,
|
rgba : RGBA8,
|
||||||
) {
|
) {
|
||||||
d := p2 - p1
|
d := p2 - p1
|
||||||
|
|
||||||
length := b2.Length(d)
|
length := math.sqrt(d.x * d.x + d.y * d.y)
|
||||||
if length < 0.001 do return
|
if length < 0.001 do return
|
||||||
|
|
||||||
axis := d / length
|
axis := d / length
|
||||||
@@ -1112,7 +1099,6 @@ solid_capsules_add :: proc(
|
|||||||
q = {c = axis.x, s = axis.y},
|
q = {c = axis.x, s = axis.y},
|
||||||
}
|
}
|
||||||
|
|
||||||
rgba := make_rgba(c, 1.0)
|
|
||||||
|
|
||||||
append(&capsule.capsules, CapsuleData{transform, radius, length, rgba})
|
append(&capsule.capsules, CapsuleData{transform, radius, length, rgba})
|
||||||
}
|
}
|
||||||
@@ -1235,86 +1221,21 @@ solid_polygon_create :: proc(polygon : ^SolidPolygon) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gl.BindBuffer(gl.ARRAY_BUFFER, polygon.vbo[0])
|
gl.BindBuffer(gl.ARRAY_BUFFER, polygon.vbo[0])
|
||||||
gl.BufferData(
|
gl.BufferData(gl.ARRAY_BUFFER, size_of([2]f32) * 6, &vertices[0], gl.STATIC_DRAW)
|
||||||
gl.ARRAY_BUFFER,
|
|
||||||
size_of([2]f32) * 6,
|
|
||||||
&vertices[0],
|
|
||||||
gl.STATIC_DRAW,
|
|
||||||
)
|
|
||||||
gl.VertexAttribPointer(vertex_attribute, 2, gl.FLOAT, gl.FALSE, 0, 0)
|
gl.VertexAttribPointer(vertex_attribute, 2, gl.FLOAT, gl.FALSE, 0, 0)
|
||||||
|
|
||||||
//
|
//
|
||||||
gl.BindBuffer(gl.ARRAY_BUFFER, polygon.vbo[1])
|
gl.BindBuffer(gl.ARRAY_BUFFER, polygon.vbo[1])
|
||||||
gl.BufferData(
|
gl.BufferData(gl.ARRAY_BUFFER, int(batch_size * size_of(PolygonData)), nil, gl.DYNAMIC_DRAW)
|
||||||
gl.ARRAY_BUFFER,
|
|
||||||
int(batch_size * size_of(PolygonData)),
|
|
||||||
nil,
|
|
||||||
gl.DYNAMIC_DRAW,
|
|
||||||
)
|
|
||||||
|
|
||||||
gl.VertexAttribPointer(
|
gl.VertexAttribPointer(instance_transform, 4, gl.FLOAT, false, size_of(PolygonData), offset_of(PolygonData, transform))
|
||||||
instance_transform,
|
gl.VertexAttribPointer(instance_point12, 4, gl.FLOAT, false, size_of(PolygonData), offset_of(PolygonData, p1))
|
||||||
4,
|
gl.VertexAttribPointer(instance_point34, 4, gl.FLOAT, false, size_of(PolygonData), offset_of(PolygonData, p3))
|
||||||
gl.FLOAT,
|
gl.VertexAttribPointer(instance_point56, 4, gl.FLOAT, false, size_of(PolygonData), offset_of(PolygonData, p5))
|
||||||
false,
|
gl.VertexAttribPointer(instance_point78, 4, gl.FLOAT, false, size_of(PolygonData), offset_of(PolygonData, p7))
|
||||||
size_of(PolygonData),
|
gl.VertexAttribIPointer(instance_point_count, 1, gl.INT, size_of(PolygonData), offset_of(PolygonData, count))
|
||||||
offset_of(PolygonData, transform),
|
gl.VertexAttribPointer(instance_radius, 1, gl.FLOAT, false, size_of(PolygonData), offset_of(PolygonData, radius))
|
||||||
)
|
gl.VertexAttribPointer(instance_color, 4, gl.UNSIGNED_BYTE, true, size_of(PolygonData), offset_of(PolygonData, color))
|
||||||
gl.VertexAttribPointer(
|
|
||||||
instance_point12,
|
|
||||||
4,
|
|
||||||
gl.FLOAT,
|
|
||||||
false,
|
|
||||||
size_of(PolygonData),
|
|
||||||
offset_of(PolygonData, p1),
|
|
||||||
)
|
|
||||||
gl.VertexAttribPointer(
|
|
||||||
instance_point34,
|
|
||||||
4,
|
|
||||||
gl.FLOAT,
|
|
||||||
false,
|
|
||||||
size_of(PolygonData),
|
|
||||||
offset_of(PolygonData, p3),
|
|
||||||
)
|
|
||||||
gl.VertexAttribPointer(
|
|
||||||
instance_point56,
|
|
||||||
4,
|
|
||||||
gl.FLOAT,
|
|
||||||
false,
|
|
||||||
size_of(PolygonData),
|
|
||||||
offset_of(PolygonData, p5),
|
|
||||||
)
|
|
||||||
gl.VertexAttribPointer(
|
|
||||||
instance_point78,
|
|
||||||
4,
|
|
||||||
gl.FLOAT,
|
|
||||||
false,
|
|
||||||
size_of(PolygonData),
|
|
||||||
offset_of(PolygonData, p7),
|
|
||||||
)
|
|
||||||
gl.VertexAttribIPointer(
|
|
||||||
instance_point_count,
|
|
||||||
1,
|
|
||||||
gl.INT,
|
|
||||||
size_of(PolygonData),
|
|
||||||
offset_of(PolygonData, count),
|
|
||||||
)
|
|
||||||
gl.VertexAttribPointer(
|
|
||||||
instance_radius,
|
|
||||||
1,
|
|
||||||
gl.FLOAT,
|
|
||||||
false,
|
|
||||||
size_of(PolygonData),
|
|
||||||
offset_of(PolygonData, radius),
|
|
||||||
)
|
|
||||||
gl.VertexAttribPointer(
|
|
||||||
instance_color,
|
|
||||||
4,
|
|
||||||
gl.UNSIGNED_BYTE,
|
|
||||||
true,
|
|
||||||
size_of(PolygonData),
|
|
||||||
offset_of(PolygonData, color),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
gl.VertexAttribDivisor(instance_transform, 1)
|
gl.VertexAttribDivisor(instance_transform, 1)
|
||||||
@@ -1339,12 +1260,11 @@ solid_polygon_add :: proc(
|
|||||||
points : [^][2]f32,
|
points : [^][2]f32,
|
||||||
count : i32,
|
count : i32,
|
||||||
radius : f32,
|
radius : f32,
|
||||||
color : b2.HexColor,
|
color : RGBA8,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
||||||
data : PolygonData
|
data : PolygonData
|
||||||
|
|
||||||
data.transform = transform
|
data.transform = transform
|
||||||
|
|
||||||
n := min(count, 8)
|
n := min(count, 8)
|
||||||
@@ -1357,7 +1277,7 @@ solid_polygon_add :: proc(
|
|||||||
|
|
||||||
data.count = n
|
data.count = n
|
||||||
data.radius = f32(radius)
|
data.radius = f32(radius)
|
||||||
data.color = make_rgba(color, 1.0)
|
data.color = color
|
||||||
|
|
||||||
append(&polygon.polygons, data)
|
append(&polygon.polygons, data)
|
||||||
}
|
}
|
||||||
@@ -1408,7 +1328,6 @@ solid_polygon_flush :: proc(polygon : ^SolidPolygon, cam : ^Camera) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TextItem :: struct
|
TextItem :: struct
|
||||||
{
|
{
|
||||||
str : string,
|
str : string,
|
||||||
@@ -1419,7 +1338,6 @@ TextItem :: struct
|
|||||||
Draw :: struct
|
Draw :: struct
|
||||||
{
|
{
|
||||||
show_ui : bool,
|
show_ui : bool,
|
||||||
debug_draw : b2.DebugDraw,
|
|
||||||
cam : Camera,
|
cam : Camera,
|
||||||
background : Background,
|
background : Background,
|
||||||
points : Point,
|
points : Point,
|
||||||
@@ -1431,162 +1349,43 @@ Draw :: struct
|
|||||||
drawCounters : bool,
|
drawCounters : bool,
|
||||||
//regular_font : im.Font,
|
//regular_font : im.Font,
|
||||||
frame_buffer : u32,
|
frame_buffer : u32,
|
||||||
|
|
||||||
|
//There should be option to draw without glyph? maybe
|
||||||
glyph : e2_glyph.GlyphState,
|
glyph : e2_glyph.GlyphState,
|
||||||
|
|
||||||
texts : [dynamic]TextItem,
|
texts : [dynamic]TextItem,
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_aabb :: proc(draw : ^Draw, aabb : b2.AABB, c : b2.HexColor) {
|
/*
|
||||||
|
draw_aabb :: proc(draw : ^Draw, aabb : [2][2]f32, rgba : RGBA8) {
|
||||||
p1 := aabb.lowerBound
|
p1 := aabb.lowerBound
|
||||||
p2 : [2]f32 = {aabb.upperBound.x, aabb.lowerBound.y}
|
p2 : [2]f32 = {aabb.upperBound.x, aabb.lowerBound.y}
|
||||||
|
|
||||||
p3 := aabb.upperBound
|
p3 := aabb.upperBound
|
||||||
p4 : [2]f32 = {aabb.lowerBound.x, aabb.upperBound.y}
|
p4 : [2]f32 = {aabb.lowerBound.x, aabb.upperBound.y}
|
||||||
|
|
||||||
lines_add(&draw.lines, p1, p2, c)
|
lines_add(&draw.lines, p1, p2, rgba)
|
||||||
lines_add(&draw.lines, p2, p3, c)
|
lines_add(&draw.lines, p2, p3, rgba)
|
||||||
lines_add(&draw.lines, p3, p4, c)
|
lines_add(&draw.lines, p3, p4, rgba)
|
||||||
lines_add(&draw.lines, p4, p1, c)
|
lines_add(&draw.lines, p4, p1, rgba)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
DrawPolygonFcn :: proc "c" (
|
|
||||||
vertices : [^][2]f32,
|
|
||||||
vertexCount : i32,
|
|
||||||
color : b2.HexColor,
|
|
||||||
ctx : rawptr,
|
|
||||||
) {
|
|
||||||
|
|
||||||
context = runtime.default_context()
|
|
||||||
draw : ^Draw = cast(^Draw)ctx
|
|
||||||
|
|
||||||
p1 := vertices[vertexCount - 1]
|
|
||||||
for i in 0 ..< vertexCount {
|
|
||||||
p2 := vertices[i]
|
|
||||||
lines_add(&draw.lines, p1, vertices[i], color)
|
|
||||||
p1 = p2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawSolidPolygonFcn :: proc "c" (
|
|
||||||
transform : Transform,
|
|
||||||
vertices : [^][2]f32,
|
|
||||||
vertexCount : i32,
|
|
||||||
radius : f32,
|
|
||||||
color : b2.HexColor,
|
|
||||||
ctx : rawptr,
|
|
||||||
) {
|
|
||||||
|
|
||||||
|
|
||||||
context = runtime.default_context()
|
|
||||||
|
|
||||||
draw : ^Draw = cast(^Draw)ctx
|
|
||||||
solid_polygon_add(
|
|
||||||
&draw.polygons,
|
|
||||||
transform,
|
|
||||||
vertices,
|
|
||||||
vertexCount,
|
|
||||||
radius,
|
|
||||||
color,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DrawCircleFcn :: proc "c" (
|
|
||||||
center : [2]f32,
|
|
||||||
radius : f32,
|
|
||||||
color : b2.HexColor,
|
|
||||||
ctx : rawptr,
|
|
||||||
) {
|
|
||||||
context = runtime.default_context()
|
|
||||||
draw : ^Draw = cast(^Draw)ctx
|
|
||||||
circle_add(&draw.circles, center, radius, color)
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawSolidCircle :: proc(
|
DrawSolidCircle :: proc(
|
||||||
circle : ^SolidCircle,
|
circle : ^SolidCircle,
|
||||||
transform : Transform,
|
transform : Transform,
|
||||||
center : [2]f32,
|
center : [2]f32,
|
||||||
radius : f32,
|
radius : f32,
|
||||||
color : b2.HexColor,
|
rgba: RGBA8,
|
||||||
) {
|
) {
|
||||||
context = runtime.default_context()
|
context = runtime.default_context()
|
||||||
|
|
||||||
transform := transform
|
transform := transform
|
||||||
|
|
||||||
rgba := make_rgba(color, 1.0)
|
|
||||||
|
|
||||||
transform.p = b2.TransformPoint(transform, center)
|
|
||||||
solid_circle_add(circle, transform, radius, rgba)
|
solid_circle_add(circle, transform, radius, rgba)
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawTransform :: proc "c" (lines : ^Lines, transform : Transform) {
|
|
||||||
context = runtime.default_context()
|
|
||||||
k_axis_scale : f32 = 0.2
|
|
||||||
p1 := transform.p
|
|
||||||
|
|
||||||
p2 := p1 + k_axis_scale * b2.Rot_GetXAxis(transform.q)
|
|
||||||
lines_add(lines, p1, p2, b2.HexColor.Red)
|
|
||||||
|
|
||||||
p2 = p1 + k_axis_scale * b2.Rot_GetYAxis(transform.q)
|
|
||||||
lines_add(lines, p1, p2, b2.HexColor.Green)
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawSolidCircleFcn :: proc "c" (
|
|
||||||
transform : Transform,
|
|
||||||
radius : f32,
|
|
||||||
color : b2.HexColor,
|
|
||||||
ctx : rawptr,
|
|
||||||
) {
|
|
||||||
|
|
||||||
context = runtime.default_context()
|
|
||||||
draw : ^Draw = cast(^Draw)ctx
|
|
||||||
DrawSolidCircle(
|
|
||||||
&draw.solid_circles,
|
|
||||||
transform,
|
|
||||||
{0, 0},
|
|
||||||
radius,
|
|
||||||
color,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawSolidCapsuleFcn :: proc "c" (
|
|
||||||
p1, p2 : [2]f32,
|
|
||||||
radius : f32,
|
|
||||||
color : b2.HexColor,
|
|
||||||
ctx : rawptr,
|
|
||||||
) {
|
|
||||||
context = runtime.default_context()
|
|
||||||
draw : ^Draw = cast(^Draw)ctx
|
|
||||||
solid_capsules_add(&draw.solid_capsules, p1, p2, radius, color)
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawSegmentFcn :: proc "c" (
|
|
||||||
p1, p2 : [2]f32,
|
|
||||||
color : b2.HexColor,
|
|
||||||
ctx : rawptr,
|
|
||||||
) {
|
|
||||||
context = runtime.default_context()
|
|
||||||
draw : ^Draw = cast(^Draw)ctx
|
|
||||||
lines_add(&draw.lines, p1, p2, color)
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawTransformFcn :: proc "c" (transform : Transform, ctx : rawptr) {
|
|
||||||
context = runtime.default_context()
|
|
||||||
draw : ^Draw = cast(^Draw)ctx
|
|
||||||
DrawTransform(&draw.lines, transform)
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawPointFcn :: proc "c" (
|
|
||||||
p : [2]f32,
|
|
||||||
size : f32,
|
|
||||||
color : b2.HexColor,
|
|
||||||
ctx : rawptr,
|
|
||||||
) {
|
|
||||||
context = runtime.default_context()
|
|
||||||
draw : ^Draw = cast(^Draw)ctx
|
|
||||||
points_add(&draw.points, p, size, color)
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawString :: proc(draw : ^Draw, x, y : int, cstr: cstring)
|
DrawString :: proc(draw : ^Draw, x, y : int, cstr: cstring)
|
||||||
{
|
{
|
||||||
ps := camera_convert_world_to_screen(&draw.cam, {f32(x), f32(y)})
|
ps := camera_convert_world_to_screen(&draw.cam, {f32(x), f32(y)})
|
||||||
@@ -1615,20 +1414,6 @@ DrawStringVec :: proc(draw : ^Draw, p : [2]f32, cstr: cstring)
|
|||||||
|
|
||||||
|
|
||||||
append(&draw.texts, TextItem{str, {f32(ps.x), f32(ps.y)}, {200,200,200,255}})
|
append(&draw.texts, TextItem{str, {f32(ps.x), f32(ps.y)}, {200,200,200,255}})
|
||||||
/*
|
|
||||||
im.DrawList_AddText(im.GetForegroundDrawList(), ps,im.GetColorU32(.Text), str)
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawStringFcn :: proc "c" (
|
|
||||||
p : [2]f32,
|
|
||||||
s : cstring,
|
|
||||||
color : b2.HexColor,
|
|
||||||
ctx : rawptr,
|
|
||||||
) {
|
|
||||||
context = runtime.default_context()
|
|
||||||
draw : ^Draw = cast(^Draw)ctx
|
|
||||||
DrawStringVec(draw, p, s)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
text_flush :: proc(draw: ^Draw)
|
text_flush :: proc(draw: ^Draw)
|
||||||
@@ -1642,7 +1427,7 @@ text_flush :: proc(draw: ^Draw)
|
|||||||
|
|
||||||
draw_flush :: proc(draw : ^Draw) {
|
draw_flush :: proc(draw : ^Draw) {
|
||||||
|
|
||||||
background_draw(&draw.background, &draw.cam)
|
//background_draw(&draw.background, &draw.cam)
|
||||||
|
|
||||||
solid_circle_flush(&draw.solid_circles, &draw.cam)
|
solid_circle_flush(&draw.solid_circles, &draw.cam)
|
||||||
solid_polygon_flush(&draw.polygons, &draw.cam)
|
solid_polygon_flush(&draw.polygons, &draw.cam)
|
||||||
@@ -1652,13 +1437,42 @@ draw_flush :: proc(draw : ^Draw) {
|
|||||||
circle_flush(&draw.circles, &draw.cam)
|
circle_flush(&draw.circles, &draw.cam)
|
||||||
text_flush(draw)
|
text_flush(draw)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
check_opengl()
|
check_opengl()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Create texture and render texture
|
||||||
|
|
||||||
|
create opengl texture when a buffer data is provided and store the textuer
|
||||||
|
The function returns the actual opengl texture_id
|
||||||
|
|
||||||
|
render_texture :: gets a texture_id and rect and displays the texture (generic but convinent for micorui)
|
||||||
|
*/
|
||||||
|
|
||||||
|
create_texutre :: proc(data: []u8, width, height: i32) -> u32
|
||||||
|
{
|
||||||
|
|
||||||
|
texture : u32
|
||||||
|
gl.GenTextures(1, &texture)
|
||||||
|
gl.BindTexture(gl.TEXTURE_2D, texture)
|
||||||
|
gl.TexImage2D( gl.TEXTURE_2D, 0, gl.RGBA8, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, raw_data(data))
|
||||||
|
|
||||||
|
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
|
||||||
|
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
|
||||||
|
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
|
||||||
|
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
|
||||||
|
|
||||||
|
gl.BindTexture(gl.TEXTURE_2D, 0)
|
||||||
|
|
||||||
|
return texture
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//This should be handled in engine code separately
|
//This should be handled in engine code separately
|
||||||
draw_create :: proc(draw : ^Draw, camera : ^Camera, font_path : string = "") {
|
draw_create :: proc(draw : ^Draw, camera : ^Camera, font_path : string = "")
|
||||||
|
{
|
||||||
|
|
||||||
background_create(&draw.background)
|
background_create(&draw.background)
|
||||||
points_create(&draw.points)
|
points_create(&draw.points)
|
||||||
@@ -1679,38 +1493,5 @@ draw_create :: proc(draw : ^Draw, camera : ^Camera, font_path : string = "") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
check_opengl()
|
check_opengl()
|
||||||
|
|
||||||
|
|
||||||
bounds : b2.AABB = {{-max(f32), -max(f32)}, {max(f32), max(f32)}}
|
|
||||||
|
|
||||||
draw.debug_draw.DrawPolygonFcn = DrawPolygonFcn
|
|
||||||
draw.debug_draw.DrawSolidPolygonFcn = DrawSolidPolygonFcn
|
|
||||||
draw.debug_draw.DrawCircleFcn = DrawCircleFcn
|
|
||||||
draw.debug_draw.DrawSolidCircleFcn = DrawSolidCircleFcn
|
|
||||||
draw.debug_draw.DrawSolidCapsuleFcn = DrawSolidCapsuleFcn
|
|
||||||
draw.debug_draw.DrawSegmentFcn = DrawSegmentFcn
|
|
||||||
draw.debug_draw.DrawTransformFcn = DrawTransformFcn
|
|
||||||
draw.debug_draw.DrawPointFcn = DrawPointFcn
|
|
||||||
draw.debug_draw.DrawStringFcn = DrawStringFcn
|
|
||||||
draw.debug_draw.drawingBounds = bounds
|
|
||||||
|
|
||||||
draw.debug_draw.useDrawingBounds = false
|
|
||||||
draw.debug_draw.drawShapes = true
|
|
||||||
draw.debug_draw.drawJoints = true
|
|
||||||
draw.debug_draw.drawJointExtras = false
|
|
||||||
draw.debug_draw.drawBounds = false
|
|
||||||
draw.debug_draw.drawMass = true
|
|
||||||
draw.debug_draw.drawContacts = false
|
|
||||||
draw.debug_draw.drawGraphColors = false
|
|
||||||
draw.debug_draw.drawContactNormals = false
|
|
||||||
draw.debug_draw.drawContactImpulses = false
|
|
||||||
draw.debug_draw.drawContactFeatures = false
|
|
||||||
draw.debug_draw.drawFrictionImpulses = false
|
|
||||||
draw.debug_draw.drawIslands = false
|
|
||||||
|
|
||||||
draw.drawCounters = true
|
|
||||||
|
|
||||||
draw.debug_draw.userContext = rawptr(draw)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#version 450 core
|
||||||
|
out vec4 FragColor;
|
||||||
|
in vec2 TexCoord;
|
||||||
|
|
||||||
|
uniform sampler2D ourTexture;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
FragColor = texture(ourTexture, TexCoord);
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#version 450 core
|
||||||
|
|
||||||
|
layout (location = 0) in vec2 aPos;
|
||||||
|
layout (location = 1) in vec2 aTexCoord;
|
||||||
|
|
||||||
|
out vec2 TexCoord;
|
||||||
|
|
||||||
|
uniform vec2 u_position; //Position in scrren coordinates (pixel)
|
||||||
|
uniform vec2 u_size; //size in pixels (width, height)
|
||||||
|
uniform vec2 u_resolution; //window resolution
|
||||||
|
|
||||||
|
void main(){
|
||||||
|
//Covert from screen coordinated to normalized device corrdinates
|
||||||
|
|
||||||
|
//Screen coordinates: origin at top-left , y down
|
||||||
|
|
||||||
|
vec2 screen_pos = aPos * u_size + u_position;
|
||||||
|
|
||||||
|
vec2 ndc;
|
||||||
|
ndc.x = (screen_pos.x / u_resolution.x) * 2.0 - 1.0;
|
||||||
|
ndc.y = 1.0 - (screen_pos.y / u_resolution.x) * 2.0;
|
||||||
|
|
||||||
|
gl_Position = vec4(ndc, 0.0, 1.0);
|
||||||
|
TexCoord = aTexCoord;
|
||||||
|
}
|
||||||
+6
-3
@@ -20,6 +20,8 @@ import mu "vendor:microui"
|
|||||||
engine_state :: struct
|
engine_state :: struct
|
||||||
{
|
{
|
||||||
window : glfw.WindowHandle,
|
window : glfw.WindowHandle,
|
||||||
|
debug_draw : b2.DebugDraw,
|
||||||
|
|
||||||
draw : e2_draw.Draw,
|
draw : e2_draw.Draw,
|
||||||
restart, pause : bool,
|
restart, pause : bool,
|
||||||
substep_count : u32,
|
substep_count : u32,
|
||||||
@@ -159,6 +161,7 @@ engine_init :: proc($GameType : typeid, state: ^engine_state, font_path : strin
|
|||||||
state.draw.show_ui = true
|
state.draw.show_ui = true
|
||||||
|
|
||||||
e2_draw.draw_create(&state.draw, &state.draw.cam, font_path)
|
e2_draw.draw_create(&state.draw, &state.draw.cam, font_path)
|
||||||
|
draw_configure_box2d(state)
|
||||||
|
|
||||||
cbor.tag_register_type({
|
cbor.tag_register_type({
|
||||||
marshal = proc(_: ^cbor.Tag_Implementation, e: cbor.Encoder, v: any) -> cbor.Marshal_Error {
|
marshal = proc(_: ^cbor.Tag_Implementation, e: cbor.Encoder, v: any) -> cbor.Marshal_Error {
|
||||||
@@ -260,8 +263,8 @@ end_frame :: proc(state: ^engine_state)
|
|||||||
|
|
||||||
for &p, i in &points do points[i] = e2_draw.camera_convert_screen_to_world(&draw.cam, p)
|
for &p, i in &points do points[i] = e2_draw.camera_convert_screen_to_world(&draw.cam, p)
|
||||||
color := c.color
|
color := c.color
|
||||||
hex_color := e2_draw.make_hex_color({color.r, color.g, color.b, color.a})
|
//hex_color := e2_draw.make_hex_color({color.r, color.g, color.b, color.a})
|
||||||
e2_draw.solid_polygon_add(&draw.polygons, {q = b2.Rot{c = 1}}, &points[0], 4, 0, hex_color)
|
e2_draw.solid_polygon_add(&draw.polygons, {q = e2_draw.Rot{c = 1}}, &points[0], 4, 0, transmute([4]u8)color)
|
||||||
}
|
}
|
||||||
case ^mu.Command_Clip:
|
case ^mu.Command_Clip:
|
||||||
{
|
{
|
||||||
@@ -278,7 +281,7 @@ end_frame :: proc(state: ^engine_state)
|
|||||||
pos.y += f32(c.rect.h)/2.0
|
pos.y += f32(c.rect.h)/2.0
|
||||||
pos = e2_draw.camera_convert_screen_to_world(&draw.cam, pos)
|
pos = e2_draw.camera_convert_screen_to_world(&draw.cam, pos)
|
||||||
|
|
||||||
e2_draw.solid_circle_add(&draw.solid_circles,{p = pos, q = b2.Rot{c = 1}} , 0.1,{255, 255, 255, 255})
|
e2_draw.solid_circle_add(&draw.solid_circles,{p = pos, q = e2_draw.Rot{c = 1}} , 0.1,{255, 255, 255, 255})
|
||||||
}else{
|
}else{
|
||||||
fmt.println(c.id)
|
fmt.println(c.id)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-9
@@ -74,15 +74,7 @@ handle_entity_mode :: proc(
|
|||||||
if is_key_pressed(state, glfw.MOUSE_BUTTON_LEFT)
|
if is_key_pressed(state, glfw.MOUSE_BUTTON_LEFT)
|
||||||
{
|
{
|
||||||
aabb : b2.AABB = {mpos, mpos + 1}
|
aabb : b2.AABB = {mpos, mpos + 1}
|
||||||
|
r := b2.World_OverlapAABB(level.engine.world_id, aabb, b2.DefaultQueryFilter(), click_query_filter, game)
|
||||||
r := b2.World_OverlapAABB(
|
|
||||||
level.engine.world_id,
|
|
||||||
aabb,
|
|
||||||
b2.DefaultQueryFilter(),
|
|
||||||
click_query_filter,
|
|
||||||
game,
|
|
||||||
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
else if is_key_pressed(state, glfw.MOUSE_BUTTON_RIGHT)
|
else if is_key_pressed(state, glfw.MOUSE_BUTTON_RIGHT)
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-2
@@ -105,7 +105,7 @@ interface_get_default :: proc(interface: ^interface_state)
|
|||||||
interface_draw_options :: proc(state: ^engine_state)
|
interface_draw_options :: proc(state: ^engine_state)
|
||||||
{
|
{
|
||||||
debug_draw := &state.debug_draw
|
debug_draw := &state.debug_draw
|
||||||
|
|
||||||
im.SliderFloat("Zoom", &state.draw.cam.zoom, 0, 100)
|
im.SliderFloat("Zoom", &state.draw.cam.zoom, 0, 100)
|
||||||
im.Checkbox("Shapes", &debug_draw.drawShapes)
|
im.Checkbox("Shapes", &debug_draw.drawShapes)
|
||||||
im.Checkbox("Joints", &debug_draw.drawJoints)
|
im.Checkbox("Joints", &debug_draw.drawJoints)
|
||||||
@@ -140,7 +140,7 @@ mu_interface_game_mode :: proc(state: ^engine_state, interface: ^interface_state
|
|||||||
{
|
{
|
||||||
if mu.begin_window(&state.mu_ctx, "Options", {200, 150, 200, 400}){
|
if mu.begin_window(&state.mu_ctx, "Options", {200, 150, 200, 400}){
|
||||||
debug_draw := &state.debug_draw
|
debug_draw := &state.debug_draw
|
||||||
|
|
||||||
mu.label(&state.mu_ctx, "Zoom")
|
mu.label(&state.mu_ctx, "Zoom")
|
||||||
mu.slider(&state.mu_ctx, &state.draw.cam.zoom,0, 100)
|
mu.slider(&state.mu_ctx, &state.draw.cam.zoom,0, 100)
|
||||||
|
|
||||||
|
|||||||
@@ -42,11 +42,12 @@ interface_edit_joint_common :: proc(joint_def : ^joint_common, interface: ^inter
|
|||||||
{
|
{
|
||||||
if joint_def.entity_a in level.static_indexes{
|
if joint_def.entity_a in level.static_indexes{
|
||||||
entity_a := interface.entity_defs[level.static_indexes[joint_def.entity_a]]
|
entity_a := interface.entity_defs[level.static_indexes[joint_def.entity_a]]
|
||||||
draw.points_add(&interface.state.draw.points, entity_a.body_def.position, 20.0, b2.HexColor.Plum)
|
draw.points_add(&interface.state.draw.points, entity_a.body_def.position, 20.0, {200, 240, 200, 200})
|
||||||
|
|
||||||
}
|
}
|
||||||
if joint_def.entity_b in level.static_indexes{
|
if joint_def.entity_b in level.static_indexes{
|
||||||
entity_b := interface.entity_defs[level.static_indexes[joint_def.entity_b]]
|
entity_b := interface.entity_defs[level.static_indexes[joint_def.entity_b]]
|
||||||
draw.points_add(&interface.state.draw.points, entity_b.body_def.position, 20.0, b2.HexColor.Plum)
|
draw.points_add(&interface.state.draw.points, entity_b.body_def.position, 20.0, {200, 240, 200, 200})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
package edit2d
|
||||||
Reference in New Issue
Block a user