Skip to content

Commit 8c9bc99

Browse files
committed
debug draw seesaw collision
1 parent e42f16b commit 8c9bc99

4 files changed

Lines changed: 38 additions & 36 deletions

File tree

objects/obj_3d_object/Draw_0.gml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,7 @@ if (self.mesh != undefined) {
55

66
for (var i = 0, n = array_length(self.cobjects); i < n; i++) {
77
var object = self.cobjects[i];
8-
var shape = object.shape;
9-
var op = shape.original_position;
10-
if (is_instanceof(shape, ColOBB)) {
11-
var os = shape.original_size;
12-
var transform = matrix_build(0, 0, 0, 0, 0, 0, os.x, os.y, os.z);
13-
transform = matrix_multiply(transform, shape.original_orientation);
14-
transform = matrix_multiply(transform, matrix_build(op.x, op.y, op.z, 0, 0, 0, 1, 1, 1));
15-
transform = matrix_multiply(transform, object_transform);
16-
17-
matrix_set(matrix_world, transform);
18-
vertex_submit(obj_game.debug_cube, pr_trianglelist, -1);
19-
matrix_set(matrix_world, matrix_build_identity());
20-
} else if (is_instanceof(shape, ColSphere)) {
21-
matrix_set(matrix_world, matrix_build(self.x + op.x, self.y + op.y, self.z + op.z, 0, 0, 0, shape.original_radius, shape.original_radius, shape.original_radius));
22-
vertex_submit(obj_game.debug_sphere, pr_trianglelist, -1);
23-
matrix_set(matrix_world, matrix_build_identity());
24-
}
8+
col_object_debug_draw(object, object_transform);
259
}
2610
} else {
2711
var position_mat = matrix_build(self.x, self.y, self.z, 0, 0, 0, 1, 1, 1);

objects/obj_3d_seesaw/Create_0.gml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ var shape_seesaw = col_shape_from_penguin(self.mesh_seesaw.collision_shapes[0],
1111
self.cobject_seesaw = new ColObject(shape_seesaw.shape, self, shape_seesaw.shape_mask, shape_seesaw.shape_group);
1212

1313
var shape_block_left = col_shape_from_penguin(self.mesh_block_left.collision_shapes[0], ECollisionMasks.DEFAULT, ECollisionMasks.DEFAULT);
14-
self.cobject_block_left = new ColObject(shape_seesaw.shape, self, shape_seesaw.shape_mask, shape_seesaw.shape_group);
14+
self.cobject_block_left = new ColObject(shape_block_left.shape, self, shape_block_left.shape_mask, shape_block_left.shape_group);
1515

1616
var shape_block_right = col_shape_from_penguin(self.mesh_block_right.collision_shapes[0], ECollisionMasks.DEFAULT, ECollisionMasks.DEFAULT);
17-
self.cobject_block_right = new ColObject(shape_seesaw.shape, self, shape_seesaw.shape_mask, shape_seesaw.shape_group);
17+
self.cobject_block_right = new ColObject(shape_block_right.shape, self, shape_block_right.shape_mask, shape_block_right.shape_group);
1818

1919
self.seesaw_angle = 0;
2020

@@ -24,14 +24,6 @@ self.matrix_block_left = undefined;
2424
self.matrix_block_right = undefined;
2525

2626
self.CalculateAllPositions = function() {
27-
if (keyboard_check(vk_pageup)) {
28-
self.state.change("tilt_left");
29-
}
30-
31-
if (keyboard_check(vk_pagedown)) {
32-
self.state.change("tilt_right");
33-
}
34-
3527
var base_position_matrix = matrix_build(self.x, self.y, self.z, 0, 0, 0, 1, 1, 1);
3628
self.matrix_base = matrix_multiply(self.rotation_mat, base_position_matrix);
3729

objects/obj_3d_seesaw/Draw_0.gml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
matrix_set(matrix_world, self.matrix_base);
2-
self.mesh.Render();
3-
4-
matrix_set(matrix_world, self.matrix_seesaw);
5-
self.mesh_seesaw.Render();
6-
matrix_set(matrix_world, self.matrix_block_left);
7-
self.mesh_block_left.Render();
8-
matrix_set(matrix_world, self.matrix_block_right);
9-
self.mesh_block_right.Render();
1+
if (keyboard_check(vk_f1)) {
2+
col_object_debug_draw(self.cobjects[0], self.matrix_base);
3+
col_object_debug_draw(self.cobject_seesaw, self.matrix_seesaw);
4+
col_object_debug_draw(self.cobject_block_left, self.matrix_block_left);
5+
col_object_debug_draw(self.cobject_block_right, self.matrix_block_right);
6+
} else {
7+
matrix_set(matrix_world, self.matrix_base);
8+
self.mesh.Render();
9+
matrix_set(matrix_world, self.matrix_seesaw);
10+
self.mesh_seesaw.Render();
11+
matrix_set(matrix_world, self.matrix_block_left);
12+
self.mesh_block_left.Render();
13+
matrix_set(matrix_world, self.matrix_block_right);
14+
self.mesh_block_right.Render();
15+
}
1016

1117
matrix_set(matrix_world, matrix_build_identity());

scripts/col_shape_from_penguin/col_shape_from_penguin.gml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,24 @@ function col_object_update_position(object, transform_matrix) {
8282
}
8383
obj_game.collision.Remove(object);
8484
obj_game.collision.Add(object);
85+
}
86+
87+
function col_object_debug_draw(object, matrix) {
88+
var shape = object.shape;
89+
var op = shape.original_position;
90+
if (is_instanceof(shape, ColOBB)) {
91+
var os = shape.original_size;
92+
var transform = matrix_build(0, 0, 0, 0, 0, 0, os.x, os.y, os.z);
93+
transform = matrix_multiply(transform, shape.original_orientation);
94+
transform = matrix_multiply(transform, matrix_build(op.x, op.y, op.z, 0, 0, 0, 1, 1, 1));
95+
transform = matrix_multiply(transform, matrix);
96+
97+
matrix_set(matrix_world, transform);
98+
vertex_submit(obj_game.debug_cube, pr_trianglelist, -1);
99+
matrix_set(matrix_world, matrix_build_identity());
100+
} else if (is_instanceof(shape, ColSphere)) {
101+
matrix_set(matrix_world, matrix_build(self.x + op.x, self.y + op.y, self.z + op.z, 0, 0, 0, shape.original_radius, shape.original_radius, shape.original_radius));
102+
vertex_submit(obj_game.debug_sphere, pr_trianglelist, -1);
103+
matrix_set(matrix_world, matrix_build_identity());
104+
}
85105
}

0 commit comments

Comments
 (0)