-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,37 @@ | ||
#include "hole.hpp" | ||
//#include <mg/Functions.h> | ||
|
||
namespace floormat { | ||
|
||
using bbox = cut_rectangle_result::bbox; | ||
|
||
cut_rectangle_result cut_rectangle(bbox input, bbox hole) | ||
{ | ||
auto ihalf = Vector2i{input.bbox_size/2}; | ||
auto istart = input.position - ihalf; | ||
auto iend = input.position + Vector2i{input.bbox_size} - ihalf; | ||
|
||
auto hhalf = Vector2i{hole.bbox_size/2}; | ||
auto hstart = hole.position - hhalf; | ||
auto hend = hole.position + Vector2i{hole.bbox_size} - hhalf; | ||
|
||
bool iempty = Vector2ui{input.bbox_size}.product() == 0; | ||
bool hempty = Vector2ui{hole.bbox_size}.product() == 0; | ||
|
||
bool outside_before_x = hend.x() >= istart.x(); | ||
bool outside_after_x = hstart.x() <= iend.x(); | ||
bool affects_start_x = hstart.x() <= istart.x(); | ||
bool affects_end_x = hend.x() >= iend.x(); | ||
|
||
//std::atomic_signal_fence(std::memory_order::relaxed); // compiler-only barrier | ||
|
||
#if 1 | ||
auto foo = uint8_t(outside_before_x << 0 | outside_after_x << 1 | affects_start_x << 2 | affects_end_x << 3 | iempty << 4 | hempty << 5); | ||
volatile auto bar = foo; | ||
(void)bar; | ||
#endif | ||
|
||
return {}; | ||
} | ||
|
||
} // namespace floormat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,37 @@ | ||
#pragma once | ||
#include "object.hpp" | ||
#include <array> | ||
|
||
namespace floormat { | ||
|
||
struct hole_proto final : object_proto | ||
{ | ||
bool affects_render : 1 = true; | ||
bool affects_physics : 1 = false; | ||
}; | ||
|
||
struct hole : object | ||
{ | ||
bool affects_render : 1 = true; | ||
bool affects_physics : 1 = false; | ||
|
||
hole(object_id id, class chunk& c, const hole_proto& proto); | ||
}; | ||
|
||
struct cut_rectangle_result | ||
{ | ||
struct bbox | ||
{ | ||
Vector2i position; | ||
Vector2ub bbox_size; | ||
}; | ||
|
||
std::array<bbox, 8> ret; | ||
uint8_t size = 0; | ||
|
||
operator ArrayView<const bbox>() const; | ||
}; | ||
|
||
cut_rectangle_result cut_rectangle(cut_rectangle_result::bbox input, cut_rectangle_result::bbox hole); | ||
|
||
} // namespace floormat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "app.hpp" | ||
|
||
namespace floormat { | ||
|
||
namespace { | ||
|
||
// tests go here | ||
void test1() | ||
{ | ||
} | ||
|
||
} // namespace | ||
|
||
void Test::test_hole() | ||
{ | ||
test1(); | ||
} | ||
|
||
} // namespace floormat |