dbf-udg

diff src/mballs.cc @ 12:1abbed71e9c9

cleanup, copyright statements and notices, readme files
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 20 Feb 2013 05:45:27 +0200
parents 5f99c4c7a9fe
children 6a836b1dc31b
line diff
     1.1 --- a/src/mballs.cc	Wed Feb 20 04:55:03 2013 +0200
     1.2 +++ b/src/mballs.cc	Wed Feb 20 05:45:27 2013 +0200
     1.3 @@ -1,13 +1,30 @@
     1.4 +/*
     1.5 +Printblobs - typography display hack
     1.6 +Copyright (C) 2013  John Tsiombikas <nuclear@member.fsf.org>
     1.7 +
     1.8 +This program is free software: you can redistribute it and/or modify
     1.9 +it under the terms of the GNU General Public License as published by
    1.10 +the Free Software Foundation, either version 3 of the License, or
    1.11 +(at your option) any later version.
    1.12 +
    1.13 +This program is distributed in the hope that it will be useful,
    1.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.16 +GNU General Public License for more details.
    1.17 +
    1.18 +You should have received a copy of the GNU General Public License
    1.19 +along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1.20 +*/
    1.21  #include <vector>
    1.22 +#include <math.h>
    1.23  #include "opengl.h"
    1.24  #include "mballs.h"
    1.25  #include "metasurf.h"
    1.26 -#include "vmath/vmath.h"
    1.27  #include "dsys.h"
    1.28  #include "udg.h"
    1.29  
    1.30  struct MetaBall {
    1.31 -	Vector3 pos;
    1.32 +	float pos[3];
    1.33  	float orbit;
    1.34  	float energy;
    1.35  	float phase_offs;
    1.36 @@ -127,9 +144,9 @@
    1.37  
    1.38  	for(size_t i=0; i<balls.size(); i++) {
    1.39  		float t = sec + balls[i].phase_offs;
    1.40 -		balls[i].pos.x = cos(t * 1.8) * balls[i].orbit;
    1.41 -		balls[i].pos.z = sin(t * 1.2) * balls[i].orbit;
    1.42 -		balls[i].pos.y = (sin(t) + cos(t * 2.0) / 2.0 + sin(t * 3.0) / 3.0) * 0.45 - (2.0 - trise * 2.0);
    1.43 +		balls[i].pos[0] = cos(t * 1.8) * balls[i].orbit;
    1.44 +		balls[i].pos[2] = sin(t * 1.2) * balls[i].orbit;
    1.45 +		balls[i].pos[1] = (sin(t) + cos(t * 2.0) / 2.0 + sin(t * 3.0) / 3.0) * 0.45 - (2.0 - trise * 2.0);
    1.46  	}
    1.47  
    1.48  	for(int i=0; i<MBALL_GRID_SZ; i++) {
    1.49 @@ -146,11 +163,12 @@
    1.50  
    1.51  static float calc_field(float x, float y, float z)
    1.52  {
    1.53 -	Vector3 pt(x, y, z);
    1.54 -
    1.55  	float sum = 0.0f;
    1.56  	for(size_t i=0; i<balls.size(); i++) {
    1.57 -		float dist_sq = (balls[i].pos - pt).length_sq();
    1.58 +		float dx = balls[i].pos[0] - x;
    1.59 +		float dy = balls[i].pos[1] - y;
    1.60 +		float dz = balls[i].pos[2] - z;
    1.61 +		float dist_sq = dx * dx + dy * dy + dz * dz;
    1.62  		if(dist_sq > 1e-6) {
    1.63  			sum += balls[i].energy / dist_sq;
    1.64  		} else {