mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Refactor decoration-related code
Split up ModApiMapgen::l_register_decoration() Define and make use of CONTAINS() and ARRLEN() macros
This commit is contained in:
parent
7c6da2f384
commit
1cb6ea6346
7 changed files with 158 additions and 142 deletions
|
@ -189,7 +189,7 @@ void Clouds::render()
|
|||
}
|
||||
|
||||
#define GETINDEX(x, z, radius) (((z)+(radius))*(radius)*2 + (x)+(radius))
|
||||
#define CONTAINS(x, z, radius) \
|
||||
#define INAREA(x, z, radius) \
|
||||
((x) >= -(radius) && (x) < (radius) && (z) >= -(radius) && (z) < (radius))
|
||||
|
||||
for(s16 zi0=-cloud_radius_i; zi0<cloud_radius_i; zi0++)
|
||||
|
@ -247,7 +247,7 @@ void Clouds::render()
|
|||
v[3].Pos.set( rx, ry,-rz);
|
||||
break;
|
||||
case 1: // back
|
||||
if(CONTAINS(xi, zi-1, cloud_radius_i)){
|
||||
if(INAREA(xi, zi-1, cloud_radius_i)){
|
||||
u32 j = GETINDEX(xi, zi-1, cloud_radius_i);
|
||||
if(grid[j])
|
||||
continue;
|
||||
|
@ -262,7 +262,7 @@ void Clouds::render()
|
|||
v[3].Pos.set(-rx,-ry,-rz);
|
||||
break;
|
||||
case 2: //right
|
||||
if(CONTAINS(xi+1, zi, cloud_radius_i)){
|
||||
if(INAREA(xi+1, zi, cloud_radius_i)){
|
||||
u32 j = GETINDEX(xi+1, zi, cloud_radius_i);
|
||||
if(grid[j])
|
||||
continue;
|
||||
|
@ -277,7 +277,7 @@ void Clouds::render()
|
|||
v[3].Pos.set( rx,-ry,-rz);
|
||||
break;
|
||||
case 3: // front
|
||||
if(CONTAINS(xi, zi+1, cloud_radius_i)){
|
||||
if(INAREA(xi, zi+1, cloud_radius_i)){
|
||||
u32 j = GETINDEX(xi, zi+1, cloud_radius_i);
|
||||
if(grid[j])
|
||||
continue;
|
||||
|
@ -292,7 +292,7 @@ void Clouds::render()
|
|||
v[3].Pos.set( rx,-ry, rz);
|
||||
break;
|
||||
case 4: // left
|
||||
if(CONTAINS(xi-1, zi, cloud_radius_i)){
|
||||
if(INAREA(xi-1, zi, cloud_radius_i)){
|
||||
u32 j = GETINDEX(xi-1, zi, cloud_radius_i);
|
||||
if(grid[j])
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue