1
0
Fork 0

Clean and optimize clouds.cpp enough to not really contain any of the small amount of non-LGPLv2/later code left

mutilcraft-mt53
Perttu Ahola 2012-06-05 18:26:10 +03:00
parent 037b259197
commit e9c123b1b9
2 changed files with 85 additions and 96 deletions

View File

@ -256,8 +256,6 @@ http://creativecommons.org/licenses/by-sa/3.0/
License of Minetest-c55 source code License of Minetest-c55 source code
----------------------------------- -----------------------------------
MOST of code:
-------------
Minetest-c55 Minetest-c55
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com> Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
@ -275,14 +273,6 @@ You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Some code:
----------
Some code in
- src/clouds.cpp
is distributed under (GPLv2 OR later) OR (LGPLv3 OR LATER), at your opinion.
The conflicting parts can be determined by looking at the version control history.
These parts will be shortly rewritten to a reasonable extent.
Irrlicht Irrlicht
--------------- ---------------

View File

@ -3,16 +3,16 @@ Minetest-c55
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com> Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU Lesser General Public License for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
@ -213,8 +213,7 @@ void Clouds::render()
v2f p0 = v2f(xi,zi)*cloud_size + world_center_of_drawing_in_noise_f; v2f p0 = v2f(xi,zi)*cloud_size + world_center_of_drawing_in_noise_f;
video::S3DVertex v[4] = video::S3DVertex v[4] = {
{
video::S3DVertex(0,0,0, 0,0,0, c_top, 0, 1), video::S3DVertex(0,0,0, 0,0,0, c_top, 0, 1),
video::S3DVertex(0,0,0, 0,0,0, c_top, 1, 1), video::S3DVertex(0,0,0, 0,0,0, c_top, 1, 1),
video::S3DVertex(0,0,0, 0,0,0, c_top, 1, 0), video::S3DVertex(0,0,0, 0,0,0, c_top, 1, 0),
@ -236,88 +235,88 @@ void Clouds::render()
{ {
switch(i) switch(i)
{ {
case 0: // top case 0: // top
for(int j=0;j<4;j++){ for(int j=0;j<4;j++){
v[j].Normal = v3f(0,1,0); v[j].Normal.set(0,1,0);
} }
v[0].Pos.X=-rx; v[0].Pos.Y= ry; v[0].Pos.Z=-rz; v[0].Pos.set(-rx, ry,-rz);
v[1].Pos.X=-rx; v[1].Pos.Y= ry; v[1].Pos.Z= rz; v[1].Pos.set(-rx, ry, rz);
v[2].Pos.X= rx; v[2].Pos.Y= ry; v[2].Pos.Z= rz; v[2].Pos.set( rx, ry, rz);
v[3].Pos.X= rx; v[3].Pos.Y= ry, v[3].Pos.Z=-rz; v[3].Pos.set( rx, ry,-rz);
break; break;
case 1: // back case 1: // back
if(CONTAINS(xi, zi-1, cloud_radius_i)){ if(CONTAINS(xi, zi-1, cloud_radius_i)){
u32 j = GETINDEX(xi, zi-1, cloud_radius_i); u32 j = GETINDEX(xi, zi-1, cloud_radius_i);
if(grid[j]) if(grid[j])
continue; continue;
} }
for(int j=0;j<4;j++){ for(int j=0;j<4;j++){
v[j].Color=c_side_1; v[j].Color = c_side_1;
v[j].Normal = v3f(0,0,-1); v[j].Normal.set(0,0,-1);
} }
v[0].Pos.X=-rx; v[0].Pos.Y= ry; v[0].Pos.Z=-rz; v[0].Pos.set(-rx, ry,-rz);
v[1].Pos.X= rx; v[1].Pos.Y= ry; v[1].Pos.Z=-rz; v[1].Pos.set( rx, ry,-rz);
v[2].Pos.X= rx; v[2].Pos.Y=-ry; v[2].Pos.Z=-rz; v[2].Pos.set( rx,-ry,-rz);
v[3].Pos.X=-rx; v[3].Pos.Y=-ry, v[3].Pos.Z=-rz; v[3].Pos.set(-rx,-ry,-rz);
break; break;
case 2: //right case 2: //right
if(CONTAINS(xi+1, zi, cloud_radius_i)){ if(CONTAINS(xi+1, zi, cloud_radius_i)){
u32 j = GETINDEX(xi+1, zi, cloud_radius_i); u32 j = GETINDEX(xi+1, zi, cloud_radius_i);
if(grid[j]) if(grid[j])
continue; continue;
} }
for(int j=0;j<4;j++){ for(int j=0;j<4;j++){
v[j].Color=c_side_2; v[j].Color = c_side_2;
v[j].Normal = v3f(1,0,0); v[j].Normal.set(1,0,0);
} }
v[0].Pos.X= rx; v[0].Pos.Y= ry; v[0].Pos.Z=-rz; v[0].Pos.set( rx, ry,-rz);
v[1].Pos.X= rx; v[1].Pos.Y= ry; v[1].Pos.Z= rz; v[1].Pos.set( rx, ry, rz);
v[2].Pos.X= rx; v[2].Pos.Y=-ry; v[2].Pos.Z= rz; v[2].Pos.set( rx,-ry, rz);
v[3].Pos.X= rx; v[3].Pos.Y=-ry, v[3].Pos.Z=-rz; v[3].Pos.set( rx,-ry,-rz);
break; break;
case 3: // front case 3: // front
if(CONTAINS(xi, zi+1, cloud_radius_i)){ if(CONTAINS(xi, zi+1, cloud_radius_i)){
u32 j = GETINDEX(xi, zi+1, cloud_radius_i); u32 j = GETINDEX(xi, zi+1, cloud_radius_i);
if(grid[j]) if(grid[j])
continue; continue;
} }
for(int j=0;j<4;j++){ for(int j=0;j<4;j++){
v[j].Color=c_side_1; v[j].Color = c_side_1;
v[j].Normal = v3f(0,0,-1); v[j].Normal.set(0,0,-1);
} }
v[0].Pos.X= rx; v[0].Pos.Y= ry; v[0].Pos.Z= rz; v[0].Pos.set( rx, ry, rz);
v[1].Pos.X=-rx; v[1].Pos.Y= ry; v[1].Pos.Z= rz; v[1].Pos.set(-rx, ry, rz);
v[2].Pos.X=-rx; v[2].Pos.Y=-ry; v[2].Pos.Z= rz; v[2].Pos.set(-rx,-ry, rz);
v[3].Pos.X= rx; v[3].Pos.Y=-ry, v[3].Pos.Z= rz; v[3].Pos.set( rx,-ry, rz);
break; break;
case 4: // left case 4: // left
if(CONTAINS(xi-1, zi, cloud_radius_i)){ if(CONTAINS(xi-1, zi, cloud_radius_i)){
u32 j = GETINDEX(xi-1, zi, cloud_radius_i); u32 j = GETINDEX(xi-1, zi, cloud_radius_i);
if(grid[j]) if(grid[j])
continue; continue;
} }
for(int j=0;j<4;j++){ for(int j=0;j<4;j++){
v[j].Color=c_side_2; v[j].Color = c_side_2;
v[j].Normal = v3f(-1,0,0); v[j].Normal.set(-1,0,0);
} }
v[0].Pos.X=-rx; v[0].Pos.Y= ry; v[0].Pos.Z= rz; v[0].Pos.set(-rx, ry, rz);
v[1].Pos.X=-rx; v[1].Pos.Y= ry; v[1].Pos.Z=-rz; v[1].Pos.set(-rx, ry,-rz);
v[2].Pos.X=-rx; v[2].Pos.Y=-ry; v[2].Pos.Z=-rz; v[2].Pos.set(-rx,-ry,-rz);
v[3].Pos.X=-rx; v[3].Pos.Y=-ry, v[3].Pos.Z= rz; v[3].Pos.set(-rx,-ry, rz);
break; break;
case 5: // bottom case 5: // bottom
for(int j=0;j<4;j++){ for(int j=0;j<4;j++){
v[j].Color=c_bottom; v[j].Color = c_bottom;
v[j].Normal = v3f(0,-1,0); v[j].Normal.set(0,-1,0);
} }
v[0].Pos.X= rx; v[0].Pos.Y=-ry; v[0].Pos.Z= rz; v[0].Pos.set( rx,-ry, rz);
v[1].Pos.X=-rx; v[1].Pos.Y=-ry; v[1].Pos.Z= rz; v[1].Pos.set(-rx,-ry, rz);
v[2].Pos.X=-rx; v[2].Pos.Y=-ry; v[2].Pos.Z=-rz; v[2].Pos.set(-rx,-ry,-rz);
v[3].Pos.X= rx; v[3].Pos.Y=-ry, v[3].Pos.Z=-rz; v[3].Pos.set( rx,-ry,-rz);
break; break;
} }
v3f pos = v3f(p0.X,m_cloud_y,p0.Y); v3f pos(p0.X, m_cloud_y, p0.Y);
for(u16 i=0; i<4; i++) for(u16 i=0; i<4; i++)
v[i].Pos += pos; v[i].Pos += pos;