mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 22:11:51 +00:00
Multiple Hitboxes
This commit is contained in:
parent
d1fbaaa28b
commit
5f551d6888
4 changed files with 42 additions and 17 deletions
|
|
@ -94,6 +94,7 @@ public:
|
|||
bool grounded = false;
|
||||
bool hidden = false;
|
||||
AABB hitbox;
|
||||
bool hitboxExplicit = false;
|
||||
BlockRotProfile rotations;
|
||||
std::string pickingItem = name+BLOCK_ITEM_SUFFIX;
|
||||
std::string scriptName = name.substr(name.find(':')+1);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <vector>
|
||||
|
||||
Chunks::Chunks(int w, int d,
|
||||
int ox, int oz,
|
||||
|
|
@ -52,7 +53,7 @@ const AABB* Chunks::isObstacleAt(float x, float y, float z){
|
|||
int ix = floor(x);
|
||||
int iy = floor(y);
|
||||
int iz = floor(z);
|
||||
voxel* v = get(ix,iy,iz);
|
||||
voxel* v = get(ix, iy, iz);
|
||||
if (v == nullptr)
|
||||
return &contentIds->getBlockDef(0)->hitbox;
|
||||
const Block* def = contentIds->getBlockDef(v->id);
|
||||
|
|
@ -62,10 +63,14 @@ const AABB* Chunks::isObstacleAt(float x, float y, float z){
|
|||
: def->hitbox;
|
||||
if (def->rt.solid) {
|
||||
return &hitbox;
|
||||
} else {
|
||||
if (hitbox.contains({x - ix, y - iy, z - iz}))
|
||||
return &hitbox;
|
||||
return nullptr;
|
||||
} else if (def->hitboxExplicit) {
|
||||
if (hitbox.contains({x - ix, y - iy, z - iz}))
|
||||
return &hitbox;
|
||||
} else {
|
||||
for (const auto& hitbox : def->modelBoxes) {
|
||||
if (hitbox.contains({x - ix, y - iy, z - iz}))
|
||||
return &hitbox;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue