mirror of
https://github.com/xtreme8000/CavEX.git
synced 2025-01-22 09:11:55 -05:00
Allow more than one block AABB (for stairs)
This commit is contained in:
parent
40b0ebed19
commit
8db63a1c78
68 changed files with 665 additions and 465 deletions
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_WOOD;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 0.5625F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 0.5625F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// TODO: add missing bed legs to mask? (difficult, many states)
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_WOOD;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -24,10 +24,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_ORGANIC;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 0.375F, 0.375F, 0.375F);
|
||||
return !entity;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 0.375F, 0.375F, 0.375F);
|
||||
return entity ? 0 : 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -24,10 +24,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_ORGANIC;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 0.875F, 1.0F, 0.875F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 0.875F, 1.0F, 0.875F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion side_top_bottom = {
|
||||
|
|
|
@ -23,11 +23,14 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_WOOL;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 0.875F - 0.125F * this->block->metadata, 0.5F, 0.875F);
|
||||
aabb_translate(x, 0.0625F * this->block->metadata, 0, 0);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x) {
|
||||
aabb_setsize(x, 0.875F - 0.125F * this->block->metadata, 0.5F, 0.875F);
|
||||
aabb_translate(x, 0.0625F * this->block->metadata, 0, 0);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// TODO: mask not correct for all states
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_WOOD;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_SAND;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return !entity;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return entity ? 0 : 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_ORGANIC;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 0.25F, 1.0F);
|
||||
return !entity;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 0.25F, 1.0F);
|
||||
return entity ? 0 : 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_ORGANIC;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -24,10 +24,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -27,31 +27,33 @@ static enum block_material getMaterial2(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
uint8_t state = ((this->block->metadata & 0x03)
|
||||
+ ((this->block->metadata & 0x04) ? 1 : 0))
|
||||
% 4;
|
||||
switch(state) {
|
||||
case 0:
|
||||
aabb_setsize(x, 0.1875F, 1.0F, 1.0F);
|
||||
aabb_translate(x, -0.40625F, 0, 0);
|
||||
break;
|
||||
case 1:
|
||||
aabb_setsize(x, 1.0F, 1.0F, 0.1875F);
|
||||
aabb_translate(x, 0, 0, -0.40625F);
|
||||
break;
|
||||
case 2:
|
||||
aabb_setsize(x, 0.1875F, 1.0F, 1.0F);
|
||||
aabb_translate(x, 0.40625F, 0, 0);
|
||||
break;
|
||||
case 3:
|
||||
aabb_setsize(x, 1.0F, 1.0F, 0.1875F);
|
||||
aabb_translate(x, 0, 0, 0.40625F);
|
||||
break;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x) {
|
||||
uint8_t state = ((this->block->metadata & 0x03)
|
||||
+ ((this->block->metadata & 0x04) ? 1 : 0))
|
||||
% 4;
|
||||
switch(state) {
|
||||
case 0:
|
||||
aabb_setsize(x, 0.1875F, 1.0F, 1.0F);
|
||||
aabb_translate(x, -0.40625F, 0, 0);
|
||||
break;
|
||||
case 1:
|
||||
aabb_setsize(x, 1.0F, 1.0F, 0.1875F);
|
||||
aabb_translate(x, 0, 0, -0.40625F);
|
||||
break;
|
||||
case 2:
|
||||
aabb_setsize(x, 0.1875F, 1.0F, 1.0F);
|
||||
aabb_translate(x, 0.40625F, 0, 0);
|
||||
break;
|
||||
case 3:
|
||||
aabb_setsize(x, 1.0F, 1.0F, 0.1875F);
|
||||
aabb_translate(x, 0, 0, 0.40625F);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_ORGANIC;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 0.9375F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 0.9375F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_WOOD;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, entity ? 1.5F : 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, entity ? 1.5F : 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion side_top_bottom = {
|
||||
|
|
|
@ -23,9 +23,9 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
return false;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -24,10 +24,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_ORGANIC;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 0.375F, 0.625F, 0.375F);
|
||||
return !entity;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 0.375F, 0.625F, 0.375F);
|
||||
return entity ? 0 : 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -24,10 +24,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_GLASS;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_GLASS;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_ORGANIC;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_ORGANIC;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_WOOD;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -24,27 +24,31 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
switch(this->block->metadata) {
|
||||
case 2:
|
||||
aabb_setsize(x, 1.0F, 1.0F, 0.125F);
|
||||
aabb_translate(x, 0, 0, 0.4375F);
|
||||
return true;
|
||||
case 3:
|
||||
aabb_setsize(x, 1.0F, 1.0F, 0.125F);
|
||||
aabb_translate(x, 0, 0, -0.4375F);
|
||||
return true;
|
||||
case 4:
|
||||
aabb_setsize(x, 0.125F, 1.0F, 1.0F);
|
||||
aabb_translate(x, 0.4375F, 0, 0);
|
||||
return true;
|
||||
case 5:
|
||||
aabb_setsize(x, 0.125F, 1.0F, 1.0F);
|
||||
aabb_translate(x, -0.4375F, 0, 0);
|
||||
return true;
|
||||
default: return false;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x) {
|
||||
switch(this->block->metadata) {
|
||||
case 2:
|
||||
aabb_setsize(x, 1.0F, 1.0F, 0.125F);
|
||||
aabb_translate(x, 0, 0, 0.4375F);
|
||||
break;
|
||||
case 3:
|
||||
aabb_setsize(x, 1.0F, 1.0F, 0.125F);
|
||||
aabb_translate(x, 0, 0, -0.4375F);
|
||||
break;
|
||||
case 4:
|
||||
aabb_setsize(x, 0.125F, 1.0F, 1.0F);
|
||||
aabb_translate(x, 0.4375F, 0, 0);
|
||||
break;
|
||||
case 5:
|
||||
aabb_setsize(x, 0.125F, 1.0F, 1.0F);
|
||||
aabb_translate(x, -0.4375F, 0, 0);
|
||||
break;
|
||||
default: aabb_setsize(x, 1.0F, 1.0F, 1.0F); break;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,13 +23,9 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
int block_height = (this->block->metadata & 0x8) ?
|
||||
16 :
|
||||
(8 - this->block->metadata) * 2 * 7 / 8;
|
||||
aabb_setsize(x, 1.0F, (float)block_height / 16.0F, 1.0F);
|
||||
return false;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_ORGANIC;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct face_occlusion sides_mask = {
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_WOOD;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_WOOD;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_WOOD;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,9 +23,9 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
return false;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -28,10 +28,11 @@ static enum block_material getMaterial2(struct block_info* this) {
|
|||
return MATERIAL_WOOD;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 0.875F, 0.0625F, 0.875F);
|
||||
return !entity;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 0.875F, 0.0625F, 0.875F);
|
||||
return entity ? 0 : 1;
|
||||
}
|
||||
|
||||
struct face_occlusion side_bottom = {
|
||||
|
|
|
@ -24,10 +24,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_WOOD;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -24,15 +24,16 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F,
|
||||
((this->block->metadata & 0x7) > 1
|
||||
&& (this->block->metadata & 0x7) < 6) ?
|
||||
0.625F :
|
||||
0.125F,
|
||||
1.0F);
|
||||
return !entity;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F,
|
||||
((this->block->metadata & 0x7) > 1
|
||||
&& (this->block->metadata & 0x7) < 6) ?
|
||||
0.625F :
|
||||
0.125F,
|
||||
1.0F);
|
||||
return entity ? 0 : 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -24,10 +24,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_ORGANIC;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 0.375F, 0.375F, 0.375F);
|
||||
return !entity;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 0.375F, 0.375F, 0.375F);
|
||||
return entity ? 0 : 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_ORGANIC;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 0.75F, 1.0F, 0.75F);
|
||||
return !entity;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 0.75F, 1.0F, 0.75F);
|
||||
return entity ? 0 : 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -24,10 +24,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_ORGANIC;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 0.375F, 0.625F, 0.375F);
|
||||
return !entity;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 0.375F, 0.625F, 0.375F);
|
||||
return entity ? 0 : 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_SAND;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -24,10 +24,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_ORGANIC;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 0.8125F, 0.8125F, 0.8125F);
|
||||
return !entity;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 0.8125F, 0.8125F, 0.8125F);
|
||||
return entity ? 0 : 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -24,10 +24,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 0.5F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 0.5F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -24,16 +24,18 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_WOOL;
|
||||
}
|
||||
|
||||
static bool getBoundingBox1(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 0.125F * (this->block->metadata + 1), 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox1(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 0.125F * (this->block->metadata + 1), 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static bool getBoundingBox2(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox2(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_ORGANIC;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -28,10 +28,43 @@ static enum block_material getMaterial2(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(entity) {
|
||||
if(x) {
|
||||
aabb_setsize(x + 0, 1.0F, 0.5F, 1.0F);
|
||||
|
||||
enum side facing
|
||||
= (enum side[4]) {SIDE_RIGHT, SIDE_LEFT, SIDE_BACK,
|
||||
SIDE_FRONT}[this->block->metadata & 3];
|
||||
|
||||
switch(facing) {
|
||||
default:
|
||||
case SIDE_FRONT:
|
||||
aabb_setsize(x + 1, 1.0F, 0.5F, 0.5F);
|
||||
aabb_translate(x + 1, 0, 0.5F, -0.25F);
|
||||
break;
|
||||
case SIDE_BACK:
|
||||
aabb_setsize(x + 1, 1.0F, 0.5F, 0.5F);
|
||||
aabb_translate(x + 1, 0, 0.5F, 0.25F);
|
||||
break;
|
||||
case SIDE_RIGHT:
|
||||
aabb_setsize(x + 1, 0.5F, 0.5F, 1.0F);
|
||||
aabb_translate(x + 1, 0.25F, 0.5F, 0);
|
||||
break;
|
||||
case SIDE_LEFT:
|
||||
aabb_setsize(x + 1, 0.5F, 0.5F, 1.0F);
|
||||
aabb_translate(x + 1, -0.25F, 0.5F, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 2;
|
||||
} else {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static struct face_occlusion side_mask = {
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -24,10 +24,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_ORGANIC;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 0.8125F, 0.8125F, 0.8125F);
|
||||
return !entity;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 0.8125F, 0.8125F, 0.8125F);
|
||||
return entity ? 0 : 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_ORGANIC;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -24,19 +24,21 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_WOOD;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 0.3125F, 0.625F, 0.3125F);
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x) {
|
||||
aabb_setsize(x, 0.3125F, 0.625F, 0.3125F);
|
||||
|
||||
switch(this->block->metadata) {
|
||||
case 1: aabb_translate(x, -0.34375F, 0.1875F, 0); break;
|
||||
case 2: aabb_translate(x, 0.34375F, 0.1875F, 0); break;
|
||||
case 3: aabb_translate(x, 0, 0.1875F, -0.34375F); break;
|
||||
case 4: aabb_translate(x, 0, 0.1875F, 0.34375F); break;
|
||||
default: aabb_setsize(x, 0.2F, 0.6F, 0.2F); break;
|
||||
switch(this->block->metadata) {
|
||||
case 1: aabb_translate(x, -0.34375F, 0.1875F, 0); break;
|
||||
case 2: aabb_translate(x, 0.34375F, 0.1875F, 0); break;
|
||||
case 3: aabb_translate(x, 0, 0.1875F, -0.34375F); break;
|
||||
case 4: aabb_translate(x, 0, 0.1875F, 0.34375F); break;
|
||||
default: aabb_setsize(x, 0.2F, 0.6F, 0.2F); break;
|
||||
}
|
||||
}
|
||||
|
||||
return !entity;
|
||||
return entity ? 0 : 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -24,32 +24,34 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_WOOD;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(this->block->metadata & 0x04) {
|
||||
switch(this->block->metadata & 0x03) {
|
||||
case 0:
|
||||
aabb_setsize(x, 1.0F, 1.0F, 0.1875F);
|
||||
aabb_translate(x, 0, 0, 0.40625F);
|
||||
break;
|
||||
case 1:
|
||||
aabb_setsize(x, 1.0F, 1.0F, 0.1875F);
|
||||
aabb_translate(x, 0, 0, -0.40625F);
|
||||
break;
|
||||
case 2:
|
||||
aabb_setsize(x, 0.1875F, 1.0F, 1.0F);
|
||||
aabb_translate(x, 0.40625F, 0, 0);
|
||||
break;
|
||||
case 3:
|
||||
aabb_setsize(x, 0.1875F, 1.0F, 1.0F);
|
||||
aabb_translate(x, -0.40625F, 0, 0);
|
||||
break;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x) {
|
||||
if(this->block->metadata & 0x04) {
|
||||
switch(this->block->metadata & 0x03) {
|
||||
case 0:
|
||||
aabb_setsize(x, 1.0F, 1.0F, 0.1875F);
|
||||
aabb_translate(x, 0, 0, 0.40625F);
|
||||
break;
|
||||
case 1:
|
||||
aabb_setsize(x, 1.0F, 1.0F, 0.1875F);
|
||||
aabb_translate(x, 0, 0, -0.40625F);
|
||||
break;
|
||||
case 2:
|
||||
aabb_setsize(x, 0.1875F, 1.0F, 1.0F);
|
||||
aabb_translate(x, 0.40625F, 0, 0);
|
||||
break;
|
||||
case 3:
|
||||
aabb_setsize(x, 0.1875F, 1.0F, 1.0F);
|
||||
aabb_translate(x, -0.40625F, 0, 0);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
aabb_setsize(x, 1.0F, 0.1875F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
aabb_setsize(x, 1.0F, 0.1875F, 1.0F);
|
||||
}
|
||||
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,13 +23,9 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_STONE;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
int block_height = (this->block->metadata & 0x8) ?
|
||||
16 :
|
||||
(8 - this->block->metadata) * 2 * 7 / 8;
|
||||
aabb_setsize(x, 1.0F, (float)block_height / 16.0F, 1.0F);
|
||||
return false;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_WOOL;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -23,10 +23,11 @@ static enum block_material getMaterial(struct block_info* this) {
|
|||
return MATERIAL_WOOD;
|
||||
}
|
||||
|
||||
static bool getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
static size_t getBoundingBox(struct block_info* this, bool entity,
|
||||
struct AABB* x) {
|
||||
if(x)
|
||||
aabb_setsize(x, 1.0F, 1.0F, 1.0F);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct face_occlusion*
|
||||
|
|
|
@ -37,7 +37,7 @@ struct block {
|
|||
uint8_t (*getTextureIndex)(struct block_info*, enum side);
|
||||
struct face_occlusion* (*getSideMask)(struct block_info*, enum side,
|
||||
struct block_info*);
|
||||
bool (*getBoundingBox)(struct block_info*, bool, struct AABB*);
|
||||
size_t (*getBoundingBox)(struct block_info*, bool, struct AABB*);
|
||||
size_t (*renderBlock)(struct displaylist*, struct block_info*, enum side,
|
||||
struct block_info*, uint8_t*, bool);
|
||||
size_t (*renderBlockAlways)(struct displaylist*, struct block_info*,
|
||||
|
|
|
@ -92,31 +92,44 @@ void entity_shadow(struct entity* e, struct AABB* a, mat4 view) {
|
|||
struct block_data blk;
|
||||
|
||||
if(entity_get_block(e, x, y, z, &blk) && blocks[blk.type]) {
|
||||
struct AABB b;
|
||||
if(blocks[blk.type]->getBoundingBox(
|
||||
&(struct block_info) {.block = &blk,
|
||||
.neighbours = NULL,
|
||||
.x = x,
|
||||
.y = y,
|
||||
.z = z},
|
||||
true, &b)) {
|
||||
aabb_translate(&b, x, y, z);
|
||||
if(a->y2 > b.y2 && aabb_intersection(a, &b)) {
|
||||
float u1 = (b.x1 - a->x1) * du;
|
||||
float u2 = (b.x2 - a->x1) * du;
|
||||
float v1 = (b.z1 - a->z1) * dv;
|
||||
float v2 = (b.z2 - a->z1) * dv;
|
||||
struct block_info blk_info = (struct block_info) {
|
||||
.block = &blk,
|
||||
.neighbours = NULL,
|
||||
.x = x,
|
||||
.y = y,
|
||||
.z = z,
|
||||
};
|
||||
|
||||
gfx_draw_quads_flt(
|
||||
4,
|
||||
(float[]) {b.x1, b.y2 + offset, b.z1, b.x2,
|
||||
b.y2 + offset, b.z1, b.x2,
|
||||
b.y2 + offset, b.z2, b.x1,
|
||||
b.y2 + offset, b.z2},
|
||||
(uint8_t[]) {0xFF, 0xFF, 0xFF, 0x60, 0xFF, 0xFF,
|
||||
0xFF, 0x60, 0xFF, 0xFF, 0xFF, 0x60,
|
||||
0xFF, 0xFF, 0xFF, 0x60},
|
||||
(float[]) {u1, v1, u2, v1, u2, v2, u1, v2});
|
||||
size_t count = blocks[blk.type]->getBoundingBox(&blk_info,
|
||||
true, NULL);
|
||||
if(count > 0) {
|
||||
struct AABB bbox[count];
|
||||
blocks[blk.type]->getBoundingBox(&blk_info, true, bbox);
|
||||
|
||||
for(size_t k = 0; k < count; k++) {
|
||||
aabb_translate(bbox + k, x, y, z);
|
||||
|
||||
if(a->y2 > bbox[k].y2
|
||||
&& aabb_intersection(a, bbox + k)) {
|
||||
float u1 = (bbox[k].x1 - a->x1) * du;
|
||||
float u2 = (bbox[k].x2 - a->x1) * du;
|
||||
float v1 = (bbox[k].z1 - a->z1) * dv;
|
||||
float v2 = (bbox[k].z2 - a->z1) * dv;
|
||||
|
||||
gfx_draw_quads_flt(
|
||||
4,
|
||||
(float[]) {bbox[k].x1, bbox[k].y2 + offset,
|
||||
bbox[k].z1, bbox[k].x2,
|
||||
bbox[k].y2 + offset, bbox[k].z1,
|
||||
bbox[k].x2, bbox[k].y2 + offset,
|
||||
bbox[k].z2, bbox[k].x1,
|
||||
bbox[k].y2 + offset, bbox[k].z2},
|
||||
(uint8_t[]) {0xFF, 0xFF, 0xFF, 0x60, 0xFF,
|
||||
0xFF, 0xFF, 0x60, 0xFF, 0xFF,
|
||||
0xFF, 0x60, 0xFF, 0xFF, 0xFF,
|
||||
0x60},
|
||||
(float[]) {u1, v1, u2, v1, u2, v2, u1, v2});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,10 +145,32 @@ void entity_shadow(struct entity* e, struct AABB* a, mat4 view) {
|
|||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
bool entity_aabb_intersection(struct entity* e, struct AABB* a,
|
||||
bool (*test)(struct block_data*, w_coord_t,
|
||||
w_coord_t, w_coord_t)) {
|
||||
assert(e && a);
|
||||
static bool entity_block_aabb_test(struct AABB* entity,
|
||||
struct block_info* blk_info) {
|
||||
assert(entity && blk_info);
|
||||
|
||||
struct block* b = blocks[blk_info->block->type];
|
||||
size_t count = b->getBoundingBox(blk_info, true, NULL);
|
||||
|
||||
if(count > 0) {
|
||||
struct AABB bbox[count];
|
||||
b->getBoundingBox(blk_info, true, bbox);
|
||||
|
||||
for(size_t k = 0; k < count; k++) {
|
||||
aabb_translate(bbox + k, blk_info->x, blk_info->y, blk_info->z);
|
||||
|
||||
if(aabb_intersection(entity, bbox + k))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool entity_intersection(struct entity* e, struct AABB* a,
|
||||
bool (*test)(struct AABB* entity,
|
||||
struct block_info* blk_info)) {
|
||||
assert(e && a && test);
|
||||
|
||||
w_coord_t min_x = floorf(a->x1);
|
||||
// need to look one further, otherwise fence block breaks
|
||||
|
@ -151,22 +186,14 @@ bool entity_aabb_intersection(struct entity* e, struct AABB* a,
|
|||
for(w_coord_t y = min_y; y < max_y; y++) {
|
||||
struct block_data blk;
|
||||
|
||||
if(entity_get_block(e, x, y, z, &blk) && blocks[blk.type]) {
|
||||
struct AABB b;
|
||||
if(blocks[blk.type]->getBoundingBox(
|
||||
if(entity_get_block(e, x, y, z, &blk) && blocks[blk.type]
|
||||
&& test(a,
|
||||
&(struct block_info) {.block = &blk,
|
||||
.neighbours = NULL,
|
||||
.x = x,
|
||||
.y = y,
|
||||
.z = z},
|
||||
true, &b)
|
||||
|| (test && test(&blk, x, y, z))) {
|
||||
aabb_translate(&b, x, y, z);
|
||||
if(aabb_intersection(a, &b)
|
||||
&& (!test || test(&blk, x, y, z)))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
.z = z}))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -174,6 +201,10 @@ bool entity_aabb_intersection(struct entity* e, struct AABB* a,
|
|||
return false;
|
||||
}
|
||||
|
||||
bool entity_aabb_intersection(struct entity* e, struct AABB* a) {
|
||||
return entity_intersection(e, a, entity_block_aabb_test);
|
||||
}
|
||||
|
||||
bool entity_intersection_threshold(struct entity* e, struct AABB* aabb,
|
||||
vec3 old_pos, vec3 new_pos,
|
||||
float* threshold) {
|
||||
|
@ -181,11 +212,11 @@ bool entity_intersection_threshold(struct entity* e, struct AABB* aabb,
|
|||
|
||||
struct AABB tmp = *aabb;
|
||||
aabb_translate(&tmp, old_pos[0], old_pos[1], old_pos[2]);
|
||||
bool a = entity_aabb_intersection(e, &tmp, NULL);
|
||||
bool a = entity_aabb_intersection(e, &tmp);
|
||||
|
||||
tmp = *aabb;
|
||||
aabb_translate(&tmp, new_pos[0], new_pos[1], new_pos[2]);
|
||||
bool b = entity_aabb_intersection(e, &tmp, NULL);
|
||||
bool b = entity_aabb_intersection(e, &tmp);
|
||||
|
||||
if(!a && b) {
|
||||
float range_min = 0.0F;
|
||||
|
@ -207,7 +238,7 @@ bool entity_intersection_threshold(struct entity* e, struct AABB* aabb,
|
|||
struct AABB dest = *aabb;
|
||||
aabb_translate(&dest, pos_mid[0], pos_mid[1], pos_mid[2]);
|
||||
|
||||
if(entity_aabb_intersection(e, &dest, NULL)) {
|
||||
if(entity_aabb_intersection(e, &dest)) {
|
||||
range_max = mid;
|
||||
} else {
|
||||
range_min = mid;
|
||||
|
|
|
@ -90,9 +90,10 @@ bool entity_get_block(struct entity* e, w_coord_t x, w_coord_t y, w_coord_t z,
|
|||
bool entity_intersection_threshold(struct entity* e, struct AABB* aabb,
|
||||
vec3 old_pos, vec3 new_pos,
|
||||
float* threshold);
|
||||
bool entity_aabb_intersection(struct entity* e, struct AABB* a,
|
||||
bool (*test)(struct block_data*, w_coord_t,
|
||||
w_coord_t, w_coord_t));
|
||||
bool entity_intersection(struct entity* e, struct AABB* a,
|
||||
bool (*test)(struct AABB* entity,
|
||||
struct block_info* blk_info));
|
||||
bool entity_aabb_intersection(struct entity* e, struct AABB* a);
|
||||
void entity_try_move(struct entity* e, vec3 pos, vec3 vel, struct AABB* bbox,
|
||||
size_t coord, bool* collision_xz, bool* on_ground);
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ static bool entity_server_tick(struct entity* e, struct server_local* s) {
|
|||
struct AABB tmp = bbox;
|
||||
aabb_translate(&tmp, e->pos[0], e->pos[1], e->pos[2]);
|
||||
|
||||
if(entity_aabb_intersection(e, &tmp, NULL)) { // is item stuck in block?
|
||||
if(entity_aabb_intersection(e, &tmp)) { // is item stuck in block?
|
||||
// find possible new position, try top/bottom last
|
||||
enum side sides[6] = {SIDE_LEFT, SIDE_RIGHT, SIDE_FRONT,
|
||||
SIDE_BACK, SIDE_TOP, SIDE_BOTTOM};
|
||||
|
@ -60,7 +60,7 @@ static bool entity_server_tick(struct entity* e, struct server_local* s) {
|
|||
struct AABB tmp2 = tmp;
|
||||
aabb_translate(&tmp2, x, y, z);
|
||||
|
||||
if(!entity_aabb_intersection(e, &tmp2, NULL)) {
|
||||
if(!entity_aabb_intersection(e, &tmp2)) {
|
||||
float threshold;
|
||||
entity_intersection_threshold(e, &bbox, new_pos, e->pos,
|
||||
&threshold);
|
||||
|
|
|
@ -21,19 +21,36 @@
|
|||
#include "../platform/input.h"
|
||||
#include "entity.h"
|
||||
|
||||
static bool test_in_lava(struct block_data* blk, w_coord_t x, w_coord_t y,
|
||||
w_coord_t z) {
|
||||
return blk->type == BLOCK_LAVA_FLOW || blk->type == BLOCK_LAVA_STILL;
|
||||
static void liquid_aabb(struct AABB* out, struct block_info* blk_info) {
|
||||
int block_height = (blk_info->block->metadata & 0x8) ?
|
||||
16 :
|
||||
(8 - blk_info->block->metadata) * 2 * 7 / 8;
|
||||
aabb_setsize(out, 1.0F, (float)block_height / 16.0F, 1.0F);
|
||||
aabb_translate(out, blk_info->x, blk_info->y, blk_info->z);
|
||||
}
|
||||
|
||||
static bool test_in_water(struct block_data* blk, w_coord_t x, w_coord_t y,
|
||||
w_coord_t z) {
|
||||
return blk->type == BLOCK_WATER_FLOW || blk->type == BLOCK_WATER_STILL;
|
||||
static bool test_in_lava(struct AABB* entity, struct block_info* blk_info) {
|
||||
if(blk_info->block->type != BLOCK_LAVA_FLOW
|
||||
&& blk_info->block->type != BLOCK_LAVA_STILL)
|
||||
return false;
|
||||
|
||||
struct AABB bbox;
|
||||
liquid_aabb(&bbox, blk_info);
|
||||
return aabb_intersection(entity, &bbox);
|
||||
}
|
||||
|
||||
static bool test_in_liquid(struct block_data* blk, w_coord_t x, w_coord_t y,
|
||||
w_coord_t z) {
|
||||
return test_in_water(blk, x, y, z) || test_in_lava(blk, x, y, z);
|
||||
static bool test_in_water(struct AABB* entity, struct block_info* blk_info) {
|
||||
if(blk_info->block->type != BLOCK_WATER_FLOW
|
||||
&& blk_info->block->type != BLOCK_WATER_STILL)
|
||||
return false;
|
||||
|
||||
struct AABB bbox;
|
||||
liquid_aabb(&bbox, blk_info);
|
||||
return aabb_intersection(entity, &bbox);
|
||||
}
|
||||
|
||||
static bool test_in_liquid(struct AABB* entity, struct block_info* blk_info) {
|
||||
return test_in_water(entity, blk_info) || test_in_lava(entity, blk_info);
|
||||
}
|
||||
|
||||
static bool entity_tick(struct entity* e) {
|
||||
|
@ -51,8 +68,8 @@ static bool entity_tick(struct entity* e) {
|
|||
aabb_translate(&bbox, e->pos[0], e->pos[1] + 1.8F / 2.0F - 1.62F,
|
||||
e->pos[2]);
|
||||
|
||||
bool in_water = entity_aabb_intersection(e, &bbox, test_in_water);
|
||||
bool in_lava = entity_aabb_intersection(e, &bbox, test_in_lava);
|
||||
bool in_water = entity_intersection(e, &bbox, test_in_water);
|
||||
bool in_lava = entity_intersection(e, &bbox, test_in_lava);
|
||||
|
||||
float slipperiness
|
||||
= (in_lava || in_water) ? 1.0F : (e->on_ground ? 0.6F : 1.0F);
|
||||
|
@ -178,7 +195,7 @@ static bool entity_tick(struct entity* e) {
|
|||
e->pos[1] + e->vel[1] + 1.8F / 2.0F - 1.62F + 0.6F,
|
||||
e->pos[2] + e->vel[2]);
|
||||
|
||||
if(!entity_aabb_intersection(e, &tmp, test_in_liquid))
|
||||
if(!entity_intersection(e, &tmp, test_in_liquid))
|
||||
e->vel[1] = 0.3F;
|
||||
}
|
||||
|
||||
|
|
|
@ -216,12 +216,18 @@ void gutil_block_selection(mat4 view_matrix, struct block_info* this) {
|
|||
assert(view_matrix && this);
|
||||
|
||||
int pad = 1;
|
||||
struct AABB box;
|
||||
|
||||
if(!blocks[this->block->type]
|
||||
|| !blocks[this->block->type]->getBoundingBox(this, false, &box))
|
||||
if(!blocks[this->block->type])
|
||||
return;
|
||||
|
||||
size_t count = blocks[this->block->type]->getBoundingBox(this, false, NULL);
|
||||
|
||||
if(!count)
|
||||
return;
|
||||
|
||||
struct AABB bbox[count];
|
||||
blocks[this->block->type]->getBoundingBox(this, false, bbox);
|
||||
|
||||
gfx_fog(false);
|
||||
gfx_lighting(false);
|
||||
gfx_blending(MODE_BLEND);
|
||||
|
@ -232,53 +238,60 @@ void gutil_block_selection(mat4 view_matrix, struct block_info* this) {
|
|||
model_view);
|
||||
gfx_matrix_modelview(model_view);
|
||||
|
||||
gfx_draw_lines(
|
||||
24,
|
||||
(int16_t[]) {
|
||||
// bottom
|
||||
-pad + box.x1 * 256, -pad + box.y1 * 256, -pad + box.z1 * 256,
|
||||
box.x2 * 256 + pad, -pad + box.y1 * 256, -pad + box.z1 * 256,
|
||||
for(size_t k = 0; k < count; k++) {
|
||||
struct AABB* box = bbox + k;
|
||||
gfx_draw_lines(
|
||||
24,
|
||||
(int16_t[]) {
|
||||
// bottom
|
||||
-pad + box->x1 * 256, -pad + box->y1 * 256,
|
||||
-pad + box->z1 * 256, box->x2 * 256 + pad, -pad + box->y1 * 256,
|
||||
-pad + box->z1 * 256,
|
||||
|
||||
-pad + box.x1 * 256, -pad + box.y1 * 256, -pad + box.z1 * 256,
|
||||
-pad + box.x1 * 256, -pad + box.y1 * 256, box.z2 * 256 + pad,
|
||||
-pad + box->x1 * 256, -pad + box->y1 * 256,
|
||||
-pad + box->z1 * 256, -pad + box->x1 * 256,
|
||||
-pad + box->y1 * 256, box->z2 * 256 + pad,
|
||||
|
||||
box.x2 * 256 + pad, -pad + box.y1 * 256, box.z2 * 256 + pad,
|
||||
box.x2 * 256 + pad, -pad + box.y1 * 256, -pad + box.z1 * 256,
|
||||
box->x2 * 256 + pad, -pad + box->y1 * 256, box->z2 * 256 + pad,
|
||||
box->x2 * 256 + pad, -pad + box->y1 * 256, -pad + box->z1 * 256,
|
||||
|
||||
box.x2 * 256 + pad, -pad + box.y1 * 256, box.z2 * 256 + pad,
|
||||
-pad + box.x1 * 256, -pad + box.y1 * 256, box.z2 * 256 + pad,
|
||||
box->x2 * 256 + pad, -pad + box->y1 * 256, box->z2 * 256 + pad,
|
||||
-pad + box->x1 * 256, -pad + box->y1 * 256, box->z2 * 256 + pad,
|
||||
|
||||
// top
|
||||
-pad + box.x1 * 256, box.y2 * 256 + pad, -pad + box.z1 * 256,
|
||||
box.x2 * 256 + pad, box.y2 * 256 + pad, -pad + box.z1 * 256,
|
||||
// top
|
||||
-pad + box->x1 * 256, box->y2 * 256 + pad, -pad + box->z1 * 256,
|
||||
box->x2 * 256 + pad, box->y2 * 256 + pad, -pad + box->z1 * 256,
|
||||
|
||||
-pad + box.x1 * 256, box.y2 * 256 + pad, -pad + box.z1 * 256,
|
||||
-pad + box.x1 * 256, box.y2 * 256 + pad, box.z2 * 256 + pad,
|
||||
-pad + box->x1 * 256, box->y2 * 256 + pad, -pad + box->z1 * 256,
|
||||
-pad + box->x1 * 256, box->y2 * 256 + pad, box->z2 * 256 + pad,
|
||||
|
||||
box.x2 * 256 + pad, box.y2 * 256 + pad, box.z2 * 256 + pad,
|
||||
box.x2 * 256 + pad, box.y2 * 256 + pad, -pad + box.z1 * 256,
|
||||
box->x2 * 256 + pad, box->y2 * 256 + pad, box->z2 * 256 + pad,
|
||||
box->x2 * 256 + pad, box->y2 * 256 + pad, -pad + box->z1 * 256,
|
||||
|
||||
box.x2 * 256 + pad, box.y2 * 256 + pad, box.z2 * 256 + pad,
|
||||
-pad + box.x1 * 256, box.y2 * 256 + pad, box.z2 * 256 + pad,
|
||||
box->x2 * 256 + pad, box->y2 * 256 + pad, box->z2 * 256 + pad,
|
||||
-pad + box->x1 * 256, box->y2 * 256 + pad, box->z2 * 256 + pad,
|
||||
|
||||
// vertical
|
||||
-pad + box.x1 * 256, -pad + box.y1 * 256, -pad + box.z1 * 256,
|
||||
-pad + box.x1 * 256, box.y2 * 256 + pad, -pad + box.z1 * 256,
|
||||
// vertical
|
||||
-pad + box->x1 * 256, -pad + box->y1 * 256,
|
||||
-pad + box->z1 * 256, -pad + box->x1 * 256, box->y2 * 256 + pad,
|
||||
-pad + box->z1 * 256,
|
||||
|
||||
box.x2 * 256 + pad, -pad + box.y1 * 256, -pad + box.z1 * 256,
|
||||
box.x2 * 256 + pad, box.y2 * 256 + pad, -pad + box.z1 * 256,
|
||||
box->x2 * 256 + pad, -pad + box->y1 * 256, -pad + box->z1 * 256,
|
||||
box->x2 * 256 + pad, box->y2 * 256 + pad, -pad + box->z1 * 256,
|
||||
|
||||
-pad + box.x1 * 256, -pad + box.y1 * 256, box.z2 * 256 + pad,
|
||||
-pad + box.x1 * 256, box.y2 * 256 + pad, box.z2 * 256 + pad,
|
||||
-pad + box->x1 * 256, -pad + box->y1 * 256, box->z2 * 256 + pad,
|
||||
-pad + box->x1 * 256, box->y2 * 256 + pad, box->z2 * 256 + pad,
|
||||
|
||||
box.x2 * 256 + pad, -pad + box.y1 * 256, box.z2 * 256 + pad,
|
||||
box.x2 * 256 + pad, box.y2 * 256 + pad, box.z2 * 256 + pad},
|
||||
(uint8_t[]) {0, 0, 0, 153, 0, 0, 0, 153, 0, 0, 0, 153, 0, 0, 0, 153,
|
||||
0, 0, 0, 153, 0, 0, 0, 153, 0, 0, 0, 153, 0, 0, 0, 153,
|
||||
0, 0, 0, 153, 0, 0, 0, 153, 0, 0, 0, 153, 0, 0, 0, 153,
|
||||
0, 0, 0, 153, 0, 0, 0, 153, 0, 0, 0, 153, 0, 0, 0, 153,
|
||||
0, 0, 0, 153, 0, 0, 0, 153, 0, 0, 0, 153, 0, 0, 0, 153,
|
||||
0, 0, 0, 153, 0, 0, 0, 153, 0, 0, 0, 153, 0, 0, 0, 153});
|
||||
box->x2 * 256 + pad, -pad + box->y1 * 256, box->z2 * 256 + pad,
|
||||
box->x2 * 256 + pad, box->y2 * 256 + pad, box->z2 * 256 + pad},
|
||||
(uint8_t[]) {0, 0, 0, 153, 0, 0, 0, 153, 0, 0, 0, 153, 0, 0,
|
||||
0, 153, 0, 0, 0, 153, 0, 0, 0, 153, 0, 0, 0, 153,
|
||||
0, 0, 0, 153, 0, 0, 0, 153, 0, 0, 0, 153, 0, 0,
|
||||
0, 153, 0, 0, 0, 153, 0, 0, 0, 153, 0, 0, 0, 153,
|
||||
0, 0, 0, 153, 0, 0, 0, 153, 0, 0, 0, 153, 0, 0,
|
||||
0, 153, 0, 0, 0, 153, 0, 0, 0, 153, 0, 0, 0, 153,
|
||||
0, 0, 0, 153, 0, 0, 0, 153, 0, 0, 0, 153});
|
||||
}
|
||||
|
||||
gfx_texture(true);
|
||||
gfx_lighting(true);
|
||||
|
|
|
@ -59,18 +59,25 @@ void particle_generate_block(struct block_info* info) {
|
|||
if(!blocks[info->block->type])
|
||||
return;
|
||||
|
||||
struct AABB aabb;
|
||||
blocks[info->block->type]->getBoundingBox(info, false, &aabb);
|
||||
size_t count = blocks[info->block->type]->getBoundingBox(info, false, NULL);
|
||||
|
||||
if(!count)
|
||||
return;
|
||||
|
||||
struct AABB aabb[count];
|
||||
blocks[info->block->type]->getBoundingBox(info, false, aabb);
|
||||
|
||||
// use only first AABB
|
||||
|
||||
float volume
|
||||
= (aabb.x2 - aabb.x1) * (aabb.y2 - aabb.y1) * (aabb.z2 - aabb.z1);
|
||||
= (aabb->x2 - aabb->x1) * (aabb->y2 - aabb->y1) * (aabb->z2 - aabb->z1);
|
||||
|
||||
uint8_t tex = blocks[info->block->type]->getTextureIndex(info, SIDE_FRONT);
|
||||
|
||||
for(int k = 0; k < volume * PARTICLES_VOLUME; k++) {
|
||||
float x = rand_flt() * (aabb.x2 - aabb.x1) + aabb.x1;
|
||||
float y = rand_flt() * (aabb.y2 - aabb.y1) + aabb.y1;
|
||||
float z = rand_flt() * (aabb.z2 - aabb.z1) + aabb.z1;
|
||||
float x = rand_flt() * (aabb->x2 - aabb->x1) + aabb->x1;
|
||||
float y = rand_flt() * (aabb->y2 - aabb->y1) + aabb->y1;
|
||||
float z = rand_flt() * (aabb->z2 - aabb->z1) + aabb->z1;
|
||||
|
||||
vec3 vel = {rand_flt() - 0.5F, rand_flt() - 0.5F, rand_flt() - 0.5F};
|
||||
glm_vec3_normalize(vel);
|
||||
|
@ -86,17 +93,30 @@ void particle_generate_side(struct block_info* info, enum side s) {
|
|||
if(!blocks[info->block->type])
|
||||
return;
|
||||
|
||||
struct AABB aabb;
|
||||
blocks[info->block->type]->getBoundingBox(info, false, &aabb);
|
||||
size_t count = blocks[info->block->type]->getBoundingBox(info, false, NULL);
|
||||
|
||||
if(!count)
|
||||
return;
|
||||
|
||||
struct AABB aabb[count];
|
||||
blocks[info->block->type]->getBoundingBox(info, false, aabb);
|
||||
|
||||
// use only first AABB
|
||||
|
||||
float area;
|
||||
switch(s) {
|
||||
case SIDE_RIGHT:
|
||||
case SIDE_LEFT: area = (aabb.y2 - aabb.y1) * (aabb.z2 - aabb.z1); break;
|
||||
case SIDE_LEFT:
|
||||
area = (aabb->y2 - aabb->y1) * (aabb->z2 - aabb->z1);
|
||||
break;
|
||||
case SIDE_BOTTOM:
|
||||
case SIDE_TOP: area = (aabb.x2 - aabb.x1) * (aabb.z2 - aabb.z1); break;
|
||||
case SIDE_TOP:
|
||||
area = (aabb->x2 - aabb->x1) * (aabb->z2 - aabb->z1);
|
||||
break;
|
||||
case SIDE_FRONT:
|
||||
case SIDE_BACK: area = (aabb.x2 - aabb.x1) * (aabb.y2 - aabb.y1); break;
|
||||
case SIDE_BACK:
|
||||
area = (aabb->x2 - aabb->x1) * (aabb->y2 - aabb->y1);
|
||||
break;
|
||||
default: return;
|
||||
}
|
||||
|
||||
|
@ -104,17 +124,17 @@ void particle_generate_side(struct block_info* info, enum side s) {
|
|||
float offset = 0.0625F;
|
||||
|
||||
for(int k = 0; k < area * PARTICLES_AREA; k++) {
|
||||
float x = rand_flt() * (aabb.x2 - aabb.x1) + aabb.x1;
|
||||
float y = rand_flt() * (aabb.y2 - aabb.y1) + aabb.y1;
|
||||
float z = rand_flt() * (aabb.z2 - aabb.z1) + aabb.z1;
|
||||
float x = rand_flt() * (aabb->x2 - aabb->x1) + aabb->x1;
|
||||
float y = rand_flt() * (aabb->y2 - aabb->y1) + aabb->y1;
|
||||
float z = rand_flt() * (aabb->z2 - aabb->z1) + aabb->z1;
|
||||
|
||||
switch(s) {
|
||||
case SIDE_LEFT: x = aabb.x1 - offset; break;
|
||||
case SIDE_RIGHT: x = aabb.x2 + offset; break;
|
||||
case SIDE_BOTTOM: y = aabb.y1 - offset; break;
|
||||
case SIDE_TOP: y = aabb.y2 + offset; break;
|
||||
case SIDE_FRONT: z = aabb.z1 - offset; break;
|
||||
case SIDE_BACK: z = aabb.z2 + offset; break;
|
||||
case SIDE_LEFT: x = aabb->x1 - offset; break;
|
||||
case SIDE_RIGHT: x = aabb->x2 + offset; break;
|
||||
case SIDE_BOTTOM: y = aabb->y1 - offset; break;
|
||||
case SIDE_TOP: y = aabb->y2 + offset; break;
|
||||
case SIDE_FRONT: z = aabb->z1 - offset; break;
|
||||
case SIDE_BACK: z = aabb->z2 + offset; break;
|
||||
default: return;
|
||||
}
|
||||
|
||||
|
@ -181,18 +201,29 @@ void particle_update() {
|
|||
struct block_data in_block = world_get_block(&gstate.world, bx, by, bz);
|
||||
|
||||
bool intersect = false;
|
||||
struct AABB aabb;
|
||||
if(blocks[in_block.type]
|
||||
&& blocks[in_block.type]->getBoundingBox(
|
||||
&(struct block_info) {.block = &in_block,
|
||||
.neighbours = NULL,
|
||||
.x = bx,
|
||||
.y = by,
|
||||
.z = bz},
|
||||
true, &aabb)) {
|
||||
aabb_translate(&aabb, bx, by, bz);
|
||||
intersect = aabb_intersection_point(&aabb, new_pos[0], new_pos[1],
|
||||
new_pos[2]);
|
||||
if(blocks[in_block.type]) {
|
||||
struct block_info blk = (struct block_info) {
|
||||
.block = &in_block,
|
||||
.neighbours = NULL,
|
||||
.x = bx,
|
||||
.y = by,
|
||||
.z = bz,
|
||||
};
|
||||
|
||||
size_t count
|
||||
= blocks[in_block.type]->getBoundingBox(&blk, true, NULL);
|
||||
if(count > 0) {
|
||||
struct AABB aabb[count];
|
||||
blocks[in_block.type]->getBoundingBox(&blk, true, aabb);
|
||||
|
||||
for(size_t k = 0; k < count; k++) {
|
||||
aabb_translate(aabb + k, bx, by, bz);
|
||||
intersect = aabb_intersection_point(aabb + k, new_pos[0],
|
||||
new_pos[1], new_pos[2]);
|
||||
if(intersect)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!intersect) {
|
||||
|
|
|
@ -397,15 +397,24 @@ bool world_block_intersection(struct world* w, struct ray* r, w_coord_t x,
|
|||
struct block_data blk = world_get_block(w, x, y, z);
|
||||
|
||||
if(blocks[blk.type]) {
|
||||
struct AABB bbox;
|
||||
struct block_info blk_info = (struct block_info) {
|
||||
.block = &blk,
|
||||
.x = x,
|
||||
.y = y,
|
||||
.z = z,
|
||||
};
|
||||
|
||||
if(blocks[blk.type]->getBoundingBox(
|
||||
&(struct block_info) {.block = &blk, .x = x, .y = y, .z = z},
|
||||
false, &bbox)) {
|
||||
aabb_translate(&bbox, x, y, z);
|
||||
return aabb_intersection_ray(&bbox, r, s);
|
||||
} else {
|
||||
return false;
|
||||
size_t count = blocks[blk.type]->getBoundingBox(&blk_info, false, NULL);
|
||||
if(count > 0) {
|
||||
struct AABB bbox[count];
|
||||
blocks[blk.type]->getBoundingBox(&blk_info, false, bbox);
|
||||
|
||||
for(size_t k = 0; k < count; k++) {
|
||||
aabb_translate(bbox + k, x, y, z);
|
||||
|
||||
if(aabb_intersection_ray(bbox + k, r, s))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -563,17 +572,26 @@ bool world_aabb_intersection(struct world* w, struct AABB* a) {
|
|||
struct block_data blk = world_get_block(w, x, y, z);
|
||||
|
||||
if(blocks[blk.type]) {
|
||||
struct AABB b;
|
||||
if(blocks[blk.type]->getBoundingBox(
|
||||
&(struct block_info) {.block = &blk,
|
||||
.neighbours = NULL,
|
||||
.x = x,
|
||||
.y = y,
|
||||
.z = z},
|
||||
true, &b)) {
|
||||
aabb_translate(&b, x, y, z);
|
||||
if(aabb_intersection(a, &b))
|
||||
return true;
|
||||
struct block_info blk_info = (struct block_info) {
|
||||
.block = &blk,
|
||||
.neighbours = NULL,
|
||||
.x = x,
|
||||
.y = y,
|
||||
.z = z,
|
||||
};
|
||||
|
||||
size_t count = blocks[blk.type]->getBoundingBox(&blk_info,
|
||||
true, NULL);
|
||||
if(count > 0) {
|
||||
struct AABB bbox[count];
|
||||
blocks[blk.type]->getBoundingBox(&blk_info, true, bbox);
|
||||
|
||||
for(size_t k = 0; k < count; k++) {
|
||||
aabb_translate(bbox + k, x, y, z);
|
||||
|
||||
if(aabb_intersection(a, bbox + k))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue