7
7
* texture coordinates are patched within the displist
9
* $Id: mball.c,v 1.28 2006/07/07 11:10:53 jiri Exp $
9
* $Id: mball.c 14883 2008-05-18 13:57:47Z ton $
11
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
11
* ***** BEGIN GPL LICENSE BLOCK *****
13
13
* This program is free software; you can redistribute it and/or
14
14
* modify it under the terms of the GNU General Public License
15
15
* as published by the Free Software Foundation; either version 2
16
* of the License, or (at your option) any later version. The Blender
17
* Foundation also sells licenses for use in proprietary software under
18
* the Blender License. See http://www.blender.org/BL/ for information
16
* of the License, or (at your option) any later version.
21
18
* This program is distributed in the hope that it will be useful,
22
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1365
1363
out_v = mbproc->function(out.x, out.y, out.z);
1367
/* find "first point" on Implicit Surface of MetaElemnt ml */
1368
converge(&in, &out, in_v, out_v, mbproc->function, &mbproc->start, mb, 0);
1370
/* indexes of CUBE, which includes "first point" */
1371
c_i= (int)floor(mbproc->start.x/mbproc->size );
1372
c_j= (int)floor(mbproc->start.y/mbproc->size );
1373
c_k= (int)floor(mbproc->start.z/mbproc->size );
1375
mbproc->start.x= mbproc->start.y= mbproc->start.z= 0.0;
1365
/* find "first points" on Implicit Surface of MetaElemnt ml */
1370
max_len = sqrt((out.x-in.x)*(out.x-in.x) + (out.y-in.y)*(out.y-in.y) + (out.z-in.z)*(out.z-in.z));
1377
/* add CUBE (with indexes c_i, c_j, c_k) to the stack,
1378
* this cube includes found point of Implicit Surface */
1379
if (ml->flag & MB_NEGATIVE)
1380
add_cube(mbproc, c_i, c_j, c_k, 2);
1382
add_cube(mbproc, c_i, c_j, c_k, 1);
1372
nx = abs((out.x - in.x)/mbproc->size);
1373
ny = abs((out.y - in.y)/mbproc->size);
1374
nz = abs((out.z - in.z)/mbproc->size);
1376
MAXN = MAX3(nx,ny,nz);
1378
dx = (out.x - in.x)/MAXN;
1379
dy = (out.y - in.y)/MAXN;
1380
dz = (out.z - in.z)/MAXN;
1383
while(len<=max_len) {
1387
/* compute value of implicite function */
1388
tmp_v = mbproc->function(workp.x, workp.y, workp.z);
1389
/* add cube to the stack, when value of implicite function crosses zero value */
1390
if((tmp_v<0.0 && workp_v>=0.0)||(tmp_v>0.0 && workp_v<=0.0)) {
1392
/* indexes of CUBE, which includes "first point" */
1393
c_i= (int)floor(workp.x/mbproc->size);
1394
c_j= (int)floor(workp.y/mbproc->size);
1395
c_k= (int)floor(workp.z/mbproc->size);
1397
/* add CUBE (with indexes c_i, c_j, c_k) to the stack,
1398
* this cube includes found point of Implicit Surface */
1399
if (ml->flag & MB_NEGATIVE)
1400
add_cube(mbproc, c_i, c_j, c_k, 2);
1402
add_cube(mbproc, c_i, c_j, c_k, 1);
1404
len = sqrt((workp.x-in.x)*(workp.x-in.x) + (workp.y-in.y)*(workp.y-in.y) + (workp.z-in.z)*(workp.z-in.z));
1708
1730
node->nodes[a]->pos= 0;
1711
size[0]/=2; size[1]/=2; size[2]/=2;
1713
1737
/* center of node */
1714
node->x= x= node->x_min + size[0];
1715
node->y= y= node->y_min + size[1];
1716
node->z= z= node->z_min + size[2];
1738
node->x = x = node->x_min + size_x;
1739
node->y = y = node->y_min + size_y;
1740
node->z = z = node->z_min + size_z;
1718
1742
/* setting up of border points of new nodes */
1719
node->nodes[0]->x_min= node->x_min;
1720
node->nodes[0]->y_min= node->y_min;
1721
node->nodes[0]->z_min= node->z_min;
1723
node->nodes[1]->x_min= x;
1724
node->nodes[1]->y_min= node->y_min;
1725
node->nodes[1]->z_min= node->z_min;
1727
node->nodes[2]->x_min= x;
1728
node->nodes[2]->y_min= y;
1729
node->nodes[2]->z_min= node->z_min;
1731
node->nodes[3]->x_min= node->x_min;
1732
node->nodes[3]->y_min= y;
1733
node->nodes[3]->z_min= node->z_min;
1735
node->nodes[4]->x_min= node->x_min;
1736
node->nodes[4]->y_min= node->y_min;
1737
node->nodes[4]->z_min= z;
1739
node->nodes[5]->x_min= x;
1740
node->nodes[5]->y_min= node->y_min;
1741
node->nodes[5]->z_min= z;
1743
node->nodes[6]->x_min= x;
1744
node->nodes[6]->y_min= y;
1745
node->nodes[6]->z_min= z;
1747
node->nodes[7]->x_min= node->x_min;
1748
node->nodes[7]->y_min= y;
1749
node->nodes[7]->z_min= z;
1743
node->nodes[0]->x_min = node->x_min;
1744
node->nodes[0]->y_min = node->y_min;
1745
node->nodes[0]->z_min = node->z_min;
1746
node->nodes[0]->x = node->nodes[0]->x_min + size_x/2;
1747
node->nodes[0]->y = node->nodes[0]->y_min + size_y/2;
1748
node->nodes[0]->z = node->nodes[0]->z_min + size_z/2;
1750
node->nodes[1]->x_min = x;
1751
node->nodes[1]->y_min = node->y_min;
1752
node->nodes[1]->z_min = node->z_min;
1753
node->nodes[1]->x = node->nodes[1]->x_min + size_x/2;
1754
node->nodes[1]->y = node->nodes[1]->y_min + size_y/2;
1755
node->nodes[1]->z = node->nodes[1]->z_min + size_z/2;
1757
node->nodes[2]->x_min = x;
1758
node->nodes[2]->y_min = y;
1759
node->nodes[2]->z_min = node->z_min;
1760
node->nodes[2]->x = node->nodes[2]->x_min + size_x/2;
1761
node->nodes[2]->y = node->nodes[2]->y_min + size_y/2;
1762
node->nodes[2]->z = node->nodes[2]->z_min + size_z/2;
1764
node->nodes[3]->x_min = node->x_min;
1765
node->nodes[3]->y_min = y;
1766
node->nodes[3]->z_min = node->z_min;
1767
node->nodes[3]->x = node->nodes[3]->x_min + size_x/2;
1768
node->nodes[3]->y = node->nodes[3]->y_min + size_y/2;
1769
node->nodes[3]->z = node->nodes[3]->z_min + size_z/2;
1771
node->nodes[4]->x_min = node->x_min;
1772
node->nodes[4]->y_min = node->y_min;
1773
node->nodes[4]->z_min = z;
1774
node->nodes[4]->x = node->nodes[4]->x_min + size_x/2;
1775
node->nodes[4]->y = node->nodes[4]->y_min + size_y/2;
1776
node->nodes[4]->z = node->nodes[4]->z_min + size_z/2;
1778
node->nodes[5]->x_min = x;
1779
node->nodes[5]->y_min = node->y_min;
1780
node->nodes[5]->z_min = z;
1781
node->nodes[5]->x = node->nodes[5]->x_min + size_x/2;
1782
node->nodes[5]->y = node->nodes[5]->y_min + size_y/2;
1783
node->nodes[5]->z = node->nodes[5]->z_min + size_z/2;
1785
node->nodes[6]->x_min = x;
1786
node->nodes[6]->y_min = y;
1787
node->nodes[6]->z_min = z;
1788
node->nodes[6]->x = node->nodes[6]->x_min + size_x/2;
1789
node->nodes[6]->y = node->nodes[6]->y_min + size_y/2;
1790
node->nodes[6]->z = node->nodes[6]->z_min + size_z/2;
1792
node->nodes[7]->x_min = node->x_min;
1793
node->nodes[7]->y_min = y;
1794
node->nodes[7]->z_min = z;
1795
node->nodes[7]->x = node->nodes[7]->x_min + size_x/2;
1796
node->nodes[7]->y = node->nodes[7]->y_min + size_y/2;
1797
node->nodes[7]->z = node->nodes[7]->z_min + size_z/2;
1751
1799
ml_p= node->elems.first;