deepstone

diff src/palman.c @ 4:c3e0bccd673e

added texture mapping
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 21 Nov 2011 11:51:23 +0200
parents 0b7f840afe4a
children 7f12c7d084d5
line diff
     1.1 --- a/src/palman.c	Mon Nov 21 10:16:09 2011 +0200
     1.2 +++ b/src/palman.c	Mon Nov 21 11:51:23 2011 +0200
     1.3 @@ -44,6 +44,18 @@
     1.4  	return 0;
     1.5  }
     1.6  
     1.7 +int palm_color_index(unsigned char r, unsigned char g, unsigned char b)
     1.8 +{
     1.9 +	int i;
    1.10 +
    1.11 +	for(i=0; i<ncol; i++) {
    1.12 +		if(colors[i].r == r && colors[i].g == g && colors[i].b == b) {
    1.13 +			return i;
    1.14 +		}
    1.15 +	}
    1.16 +	return -1;
    1.17 +}
    1.18 +
    1.19  /* TODO: build an octree */
    1.20  int palm_build(void)
    1.21  {
    1.22 @@ -94,14 +106,12 @@
    1.23  
    1.24  int palm_color_base(unsigned char r, unsigned char g, unsigned char b)
    1.25  {
    1.26 -	int i;
    1.27 +	int c;
    1.28  
    1.29 -	for(i=0; i<pcol; i++) {
    1.30 -		if(colors[i].r == r && colors[i].g == g && colors[i].b == b) {
    1.31 -			return base_index[i];
    1.32 -		}
    1.33 +	if((c = palm_color_index(r, g, b)) == -1) {
    1.34 +		return -1;
    1.35  	}
    1.36 -	return -1;
    1.37 +	return base_index[c];
    1.38  }
    1.39  
    1.40  int palm_color_range(void)