clray
diff src/mesh.cc @ 14:29f9330cfa4b
trying to debug the bloody thing
author | John Tsiombikas |
---|---|
date | Sat, 07 Aug 2010 03:36:36 +0100 |
parents | 407935b73af3 |
children | 754faf15ba36 |
line diff
1.1 --- a/src/mesh.cc Wed Aug 04 04:51:06 2010 +0100 1.2 +++ b/src/mesh.cc Sat Aug 07 03:36:36 2010 +0100 1.3 @@ -125,6 +125,11 @@ 1.4 return true; 1.5 } 1.6 1.7 +int Scene::get_num_meshes() const 1.8 +{ 1.9 + return (int)meshes.size(); 1.10 +} 1.11 + 1.12 int Scene::get_num_faces() const 1.13 { 1.14 int num_faces = 0; 1.15 @@ -135,6 +140,27 @@ 1.16 return num_faces; 1.17 } 1.18 1.19 +int Scene::get_num_materials() const 1.20 +{ 1.21 + return (int)matlib.size(); 1.22 +} 1.23 + 1.24 +Material *Scene::get_materials() 1.25 +{ 1.26 + if(matlib.empty()) { 1.27 + return 0; 1.28 + } 1.29 + return &matlib[0]; 1.30 +} 1.31 + 1.32 +const Material *Scene::get_materials() const 1.33 +{ 1.34 + if(matlib.empty()) { 1.35 + return 0; 1.36 + } 1.37 + return &matlib[0]; 1.38 +} 1.39 + 1.40 1.41 #define INVALID_IDX INT_MIN 1.42 1.43 @@ -638,7 +664,9 @@ 1.44 char *pathname = (char*)alloca(res_len + fnamelen + 2); 1.45 memcpy(pathname, beg, res_len); 1.46 pathname[res_len] = 0; 1.47 - strcat(pathname, "/"); 1.48 + if(res_len) { 1.49 + strcat(pathname, "/"); 1.50 + } 1.51 strcat(pathname, fname); 1.52 1.53 if((fp = fopen(pathname, mode))) { 1.54 @@ -648,6 +676,7 @@ 1.55 } 1.56 1.57 beg += res_len; 1.58 + if(*beg == ':') beg++; 1.59 } 1.60 return false; 1.61 } 1.62 @@ -662,7 +691,11 @@ 1.63 strncpy(buf, str, PATH_MAX); 1.64 char *ptr = strrchr(buf, '/'); 1.65 1.66 - if(ptr && *ptr) *ptr = 0; 1.67 + if(ptr && *ptr) { 1.68 + *ptr = 0; 1.69 + } else { 1.70 + strcpy(buf, "."); 1.71 + } 1.72 } 1.73 return buf; 1.74 }