fixed matrix math order
This commit is contained in:
parent
2469b45694
commit
9b550856fb
5 changed files with 125 additions and 60 deletions
|
|
@ -545,10 +545,10 @@ program_update :: proc() {
|
|||
for draggable in program.mouse_draggables {
|
||||
switch draggable in draggable {
|
||||
case MouseDraggable_Point:
|
||||
position_world := (v3{**draggable.ref^, 1.0} * grid_to_world_matrix).xy
|
||||
position_world := matrix3_transform_v2(grid_to_world_matrix, draggable.ref^)
|
||||
rl.DrawCircleV(position_world, program.mouse_draggable_radius, ANIMATION_COLOR_ORIGIN)
|
||||
case MouseDraggable_RectangleCornerData:
|
||||
position_world := (v3{**draggable.corner_ref^, 1.0} * grid_to_world_matrix).xy
|
||||
position_world := matrix3_transform_v2(grid_to_world_matrix, draggable.corner_ref^)
|
||||
rl.DrawCircleV(position_world, program.mouse_draggable_radius, ANIMATION_COLOR_ORIGIN)
|
||||
case MouseDraggable_RectangleData:
|
||||
}
|
||||
|
|
@ -608,17 +608,31 @@ program_add_rotation_matrix :: proc(angle: f32) {
|
|||
case .Degrees: radians = linalg.RAD_PER_DEG * angle
|
||||
case .Radians: radians = angle
|
||||
}
|
||||
rotmat := linalg.matrix2_rotate_f32(angle)
|
||||
fmt.bprint(value_strings[0][:], rotmat[0, 0])
|
||||
values[0] = rotmat[0, 0]
|
||||
fmt.bprint(value_strings[1][:], rotmat[0, 1])
|
||||
values[1] = rotmat[0, 1]
|
||||
fmt.bprint(value_strings[3][:], rotmat[1, 0])
|
||||
values[3] = rotmat[1, 0]
|
||||
fmt.bprint(value_strings[4][:], rotmat[1, 1])
|
||||
values[4] = rotmat[1, 1]
|
||||
|
||||
a := linalg.cos(radians)
|
||||
b := linalg.sin(radians)
|
||||
fmt.bprint(value_strings[0][:], a)
|
||||
values[0] = a
|
||||
fmt.bprint(value_strings[1][:], -b)
|
||||
values[1] = b
|
||||
fmt.bprint(value_strings[3][:], b)
|
||||
values[3] = a
|
||||
fmt.bprint(value_strings[4][:], a)
|
||||
values[4] = a
|
||||
fmt.bprint(value_strings[8][:], 1)
|
||||
values[8] = 1.0
|
||||
|
||||
// rotmat := linalg.matrix2_rotate_f32(angle)
|
||||
// fmt.bprint(value_strings[0][:], rotmat[0, 0])
|
||||
// values[0] = rotmat[0, 0]
|
||||
// fmt.bprint(value_strings[1][:], rotmat[0, 1])
|
||||
// values[1] = rotmat[0, 1]
|
||||
// fmt.bprint(value_strings[1][:], rotmat[1, 0])
|
||||
// values[3] = rotmat[1, 0]
|
||||
// fmt.bprint(value_strings[4][:], rotmat[1, 1])
|
||||
// values[4] = rotmat[1, 1]
|
||||
// fmt.bprint(value_strings[8][:], 1)
|
||||
// values[8] = 1.0
|
||||
}
|
||||
|
||||
program_build_dialog_ui :: proc(ctx: ^ui.Context, dialog_type: ProgramDialogType) -> []ui.Element {
|
||||
|
|
@ -847,21 +861,21 @@ program_handle_mouse :: proc(mouse_state: MouseState, top_bar_container, matrix_
|
|||
for draggable in program.mouse_draggables {
|
||||
switch draggable in draggable {
|
||||
case MouseDraggable_Point:
|
||||
circle_position := (v3{**draggable.ref^, 1.0} * grid_to_world_matrix).xy
|
||||
circle_position := matrix3_transform_v2(grid_to_world_matrix, draggable.ref^)
|
||||
if linalg.distance(mouse, circle_position) <= program.mouse_draggable_radius {
|
||||
program.mouse_current_draggable = draggable
|
||||
mouse_state = .DraggingDraggable
|
||||
break state_label
|
||||
}
|
||||
case MouseDraggable_RectangleCornerData:
|
||||
circle_position := (v3{**draggable.corner_ref^, 1.0} * grid_to_world_matrix).xy
|
||||
circle_position := matrix3_transform_v2(grid_to_world_matrix, draggable.corner_ref^)
|
||||
if linalg.distance(mouse, circle_position) <= program.mouse_draggable_radius {
|
||||
program.mouse_current_draggable = draggable
|
||||
mouse_state = .DraggingDraggable
|
||||
break state_label
|
||||
}
|
||||
case MouseDraggable_RectangleData:
|
||||
corners_world := rectangle_corners_transform_mat3(draggable.corners^, grid_to_world_matrix)
|
||||
corners_world := rectangle_corners_transform_mat3(grid_to_world_matrix, draggable.corners^)
|
||||
rect := rect_from(corners_world.tl, corners_world.tr, corners_world.br, corners_world.bl)
|
||||
if rect_has_point(rect, mouse) {
|
||||
program.mouse_current_draggable = draggable
|
||||
|
|
@ -884,9 +898,9 @@ program_handle_mouse :: proc(mouse_state: MouseState, top_bar_container, matrix_
|
|||
draggable := program.mouse_current_draggable
|
||||
switch draggable in draggable {
|
||||
case MouseDraggable_Point:
|
||||
draggable.ref^ = (v3{**mouse, 1.0} * world_to_grid_matrix).xy
|
||||
draggable.ref^ = matrix3_transform_v2(world_to_grid_matrix, mouse)
|
||||
case MouseDraggable_RectangleCornerData:
|
||||
position := (v3{**mouse, 1.0} * world_to_grid_matrix).xy
|
||||
position := matrix3_transform_v2(world_to_grid_matrix, mouse)
|
||||
corners := rectangle_corners_move_corner(draggable.corners_ref^, position, draggable.corner)
|
||||
draggable.corners_ref^ = corners
|
||||
case MouseDraggable_RectangleData:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue