"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "layer1/Extrude.cpp" between
pymol-open-source-2.2.0.tar.gz and pymol-open-source-2.3.0.tar.gz

About: PyMOL is a Python-enhanced molecular graphics tool. It excels at 3D visualization of proteins, small molecules, density, surfaces, and trajectories. It also includes molecular editing, ray tracing, and movies. Open Source version.

Extrude.cpp  (pymol-open-source-2.2.0):Extrude.cpp  (pymol-open-source-2.3.0)
skipping to change at line 28 skipping to change at line 28
#include"os_predef.h" #include"os_predef.h"
#include"os_std.h" #include"os_std.h"
#include"os_gl.h" #include"os_gl.h"
#include"Extrude.h" #include"Extrude.h"
#include"Base.h" #include"Base.h"
#include"OOMac.h" #include"OOMac.h"
#include"Setting.h" #include"Setting.h"
#include"Feedback.h" #include"Feedback.h"
static
void ExtrudeInit(PyMOLGlobals * G, CExtrude * I); void ExtrudeInit(PyMOLGlobals * G, CExtrude * I);
#define CopyArray(dst,src,type,count) memcpy(dst,src,sizeof(type)*(count)) #define CopyArray(dst,src,type,count) memcpy(dst,src,sizeof(type)*(count))
CExtrude *ExtrudeCopyPointsNormalsColors(CExtrude * orig) CExtrude *ExtrudeCopyPointsNormalsColors(CExtrude * orig)
{ {
int ok = true; int ok = true;
OOAlloc(orig->G, CExtrude); OOAlloc(orig->G, CExtrude);
CHECKOK(ok, I); CHECKOK(ok, I);
if (ok) if (ok)
ExtrudeInit(orig->G, I); ExtrudeInit(orig->G, I);
if (ok) if (ok)
ok &= ExtrudeAllocPointsNormalsColors(I, orig->N); ok &= ExtrudeAllocPointsNormalsColors(I, orig->N);
if (ok){ if (ok){
CopyArray(I->p, orig->p, float, 3 * I->N); CopyArray(I->p, orig->p, float, 3 * I->N);
CopyArray(I->n, orig->n, float, 9 * I->N); CopyArray(I->n, orig->n, float, 9 * I->N);
CopyArray(I->c, orig->c, float, 3 * I->N); CopyArray(I->c, orig->c, float, 3 * I->N);
CopyArray(I->alpha, orig->alpha, float, I->N);
CopyArray(I->i, orig->i, unsigned int, I->N); CopyArray(I->i, orig->i, unsigned int, I->N);
CopyArray(I->sf, orig->sf, float, I->N); /* PUTTY: scale factors */ CopyArray(I->sf, orig->sf, float, I->N); /* PUTTY: scale factors */
} else { } else {
ExtrudeFree(I); ExtrudeFree(I);
I = NULL; I = NULL;
} }
return (I); return (I);
} }
void ExtrudeInit(PyMOLGlobals * G, CExtrude * I) void ExtrudeInit(PyMOLGlobals * G, CExtrude * I)
{ {
I->G = G; I->G = G;
I->N = 0; I->N = 0;
I->p = NULL; I->p = NULL;
I->n = NULL; I->n = NULL;
I->c = NULL; I->c = NULL;
I->alpha = nullptr;
I->i = NULL; I->i = NULL;
I->sv = NULL; /* shape vertices */ I->sv = NULL; /* shape vertices */
I->sn = NULL; /* shape normals */ I->sn = NULL; /* shape normals */
I->tv = NULL; /* transformed vertices */ I->tv = NULL; /* transformed vertices */
I->tn = NULL; /* transformed normals */ I->tn = NULL; /* transformed normals */
I->Ns = 0; /* number of shape points */ I->Ns = 0; /* number of shape points */
I->sf = NULL; I->sf = NULL;
} }
skipping to change at line 706 skipping to change at line 709
copy3f(normal, tmp3f); copy3f(normal, tmp3f);
invert3f(tmp3f); invert3f(tmp3f);
normal = tmp3f; normal = tmp3f;
} else { } else {
b_end = I->Ns * 2 + 1; b_end = I->Ns * 2 + 1;
b_incr = 1; b_incr = 1;
} }
CGOBegin(cgo, GL_TRIANGLE_FAN); CGOBegin(cgo, GL_TRIANGLE_FAN);
CGOColorv(cgo, color ? color : (I->c + 3 * index)); CGOColorv(cgo, color ? color : (I->c + 3 * index));
CGOAlpha(cgo, I->alpha[index]);
CGOPickColor(cgo, I->i[index], cPickableAtom); CGOPickColor(cgo, I->i[index], cPickableAtom);
CGONormalv(cgo, normal); // (tmp3f again free to use) CGONormalv(cgo, normal); // (tmp3f again free to use)
CGOVertexv(cgo, vertex); // center CGOVertexv(cgo, vertex); // center
// Indexing trickery: going in a loop, visiting first index twice to // Indexing trickery: going in a loop, visiting first index twice to
// close the loop. Iterating backwards in case of `inv_dir`. // close the loop. Iterating backwards in case of `inv_dir`.
for (int b = I->Ns; b != b_end; b += b_incr) { for (int b = I->Ns; b != b_end; b += b_incr) {
transform33Tf3f(base33, I->sv + (b % I->Ns) * 3, tmp3f); transform33Tf3f(base33, I->sv + (b % I->Ns) * 3, tmp3f);
add3f(vertex, tmp3f, tmp3f); add3f(vertex, tmp3f, tmp3f);
CGOVertexv(cgo, tmp3f); CGOVertexv(cgo, tmp3f);
skipping to change at line 737 skipping to change at line 741
* use_spheres: do round caps with spheres instead of triangles * use_spheres: do round caps with spheres instead of triangles
* dash: if > 0, skip every segment which is a multiple of `dash` * dash: if > 0, skip every segment which is a multiple of `dash`
*/ */
int ExtrudeCGOSurfaceTube(CExtrude * I, CGO * cgo, int cap, const float *color_o verride, bool use_spheres, int dash) int ExtrudeCGOSurfaceTube(CExtrude * I, CGO * cgo, int cap, const float *color_o verride, bool use_spheres, int dash)
{ {
int a, b; int a, b;
unsigned int *i; unsigned int *i;
float *v; float *v;
float *n; float *n;
float *c; float *c;
const float *alpha;
float *sv, *sn, *tv, *tn, *tv1, *tn1, *TV = NULL, *TN = NULL; float *sv, *sn, *tv, *tn, *tv1, *tn1, *TV = NULL, *TN = NULL;
int start, stop; int start, stop;
int ok = true; int ok = true;
PRINTFD(I->G, FB_Extrude) PRINTFD(I->G, FB_Extrude)
" ExtrudeCGOSurfaceTube-DEBUG: entered.\n" ENDFD; " ExtrudeCGOSurfaceTube-DEBUG: entered.\n" ENDFD;
if(I->N && I->Ns) { if(I->N && I->Ns) {
TV = Alloc(float, 3 * (I->Ns + 1) * I->N); TV = Alloc(float, 3 * (I->Ns + 1) * I->N);
CHECKOK(ok, TV); CHECKOK(ok, TV);
if (ok) if (ok)
skipping to change at line 800 skipping to change at line 805
// second loop: circumferential, setting up axial triangle strips // second loop: circumferential, setting up axial triangle strips
for(b = 0; ok && b < I->Ns; b++) { for(b = 0; ok && b < I->Ns; b++) {
if(SettingGetGlobal_i(I->G, cSetting_cartoon_debug) < 1.5) if(SettingGetGlobal_i(I->G, cSetting_cartoon_debug) < 1.5)
ok &= CGOBegin(cgo, GL_TRIANGLE_STRIP); ok &= CGOBegin(cgo, GL_TRIANGLE_STRIP);
else { else {
ok &= CGOBegin(cgo, GL_LINE_STRIP); ok &= CGOBegin(cgo, GL_LINE_STRIP);
} }
if (ok){ if (ok){
c = I->c + a_start * 3; c = I->c + a_start * 3;
alpha = I->alpha + a_start;
i = I->i + a_start; i = I->i + a_start;
tv = TV + 3 * (a_start + b * I->N); tv = TV + 3 * (a_start + b * I->N);
tn = TN + 3 * (a_start + b * I->N); tn = TN + 3 * (a_start + b * I->N);
tv1 = tv + 3 * I->N; tv1 = tv + 3 * I->N;
tn1 = tn + 3 * I->N; tn1 = tn + 3 * I->N;
// third loop: axial, segments within one "dash" // third loop: axial, segments within one "dash"
for(a = a_start; ok && a < a_end; ++a) { for(a = a_start; ok && a < a_end; ++a) {
if(color_override && (b > start) && (b < stop)) if(color_override && (b > start) && (b < stop))
ok &= CGOColorv(cgo, color_override); ok &= CGOColorv(cgo, color_override);
else else
ok &= CGOColorv(cgo, c); ok &= CGOColorv(cgo, c);
if (ok){
ok &= CGOAlpha(cgo, *alpha);
}
if (ok) if (ok)
ok &= CGOPickColor(cgo, *i, cPickableAtom); ok &= CGOPickColor(cgo, *i, cPickableAtom);
if (ok) if (ok)
ok &= CGONormalv(cgo, tn); ok &= CGONormalv(cgo, tn);
if (ok) if (ok)
ok &= CGOVertexv(cgo, tv); ok &= CGOVertexv(cgo, tv);
tn += 3; tn += 3;
tv += 3; tv += 3;
if (ok) if (ok)
ok &= CGONormalv(cgo, tn1); ok &= CGONormalv(cgo, tn1);
if (ok) if (ok)
ok &= CGOVertexv(cgo, tv1); ok &= CGOVertexv(cgo, tv1);
tn1 += 3; tn1 += 3;
tv1 += 3; tv1 += 3;
c += 3; c += 3;
alpha++;
i++; i++;
} }
} }
if (ok) if (ok)
ok &= CGOEnd(cgo); ok &= CGOEnd(cgo);
if (ok) if (ok)
ok &= CGOPickColor(cgo, -1, cPickableNoPick); ok &= CGOPickColor(cgo, -1, cPickableNoPick);
} }
if (cap == 1) { if (cap == 1) {
skipping to change at line 876 skipping to change at line 886
cross_product3f(p0, p1, p2); cross_product3f(p0, p1, p2);
normalize3f(p1); normalize3f(p1);
normalize3f(p2); normalize3f(p2);
} }
if (ok){ if (ok){
if(color_override) if(color_override)
ok &= CGOColorv(cgo, color_override); ok &= CGOColorv(cgo, color_override);
else else
ok &= CGOColorv(cgo, I->c); ok &= CGOColorv(cgo, I->c);
} }
if (ok){
ok &= CGOAlpha(cgo, I->alpha[0]);
}
if (ok) if (ok)
ok &= CGOPickColor(cgo, I->i[0], cPickableAtom); ok &= CGOPickColor(cgo, I->i[0], cPickableAtom);
if (ok){ if (ok){
v = I->p; v = I->p;
if (use_spheres){ if (use_spheres){
ok &= CGOSphere(cgo, v, I->r); // this matches the Cylinder ok &= CGOSphere(cgo, v, I->r); // this matches the Cylinder
} else { } else {
/* If we don't use spheres, then we need to have the rounded cap /* If we don't use spheres, then we need to have the rounded cap
* line up with the geometry perfectly. We generate the cap using * line up with the geometry perfectly. We generate the cap using
* spheracle coordinates, then for the last line (i.e., last=true) * spheracle coordinates, then for the last line (i.e., last=true)
skipping to change at line 966 skipping to change at line 979
transform33Tf3f(n, I->sv, p1); transform33Tf3f(n, I->sv, p1);
cross_product3f(p0, p1, p2); cross_product3f(p0, p1, p2);
normalize3f(p1); normalize3f(p1);
normalize3f(p2); normalize3f(p2);
if(color_override) if(color_override)
ok &= CGOColorv(cgo, color_override); ok &= CGOColorv(cgo, color_override);
else else
ok &= CGOColorv(cgo, I->c + 3 * (I->N - 1)); ok &= CGOColorv(cgo, I->c + 3 * (I->N - 1));
} }
if (ok){
ok &= CGOAlpha(cgo, I->alpha[I->N - 1]);
}
if (ok) if (ok)
ok &= CGOPickColor(cgo, I->i[I->N - 1], cPickableAtom); ok &= CGOPickColor(cgo, I->i[I->N - 1], cPickableAtom);
if (ok){ if (ok){
if (use_spheres){ if (use_spheres){
ok &= CGOSphere(cgo, v, I->r); // this matches the Cylinder ok &= CGOSphere(cgo, v, I->r); // this matches the Cylinder
} else { } else {
/* If we don't use spheres, then we need to have the rounded cap /* If we don't use spheres, then we need to have the rounded cap
* line up with the geometry perfectly. We generate the cap using * line up with the geometry perfectly. We generate the cap using
* spheracle coordinates, then for the last line (i.e., last=true) * spheracle coordinates, then for the last line (i.e., last=true)
skipping to change at line 1049 skipping to change at line 1065
FreeP(TN); FreeP(TN);
} }
PRINTFD(I->G, FB_Extrude) PRINTFD(I->G, FB_Extrude)
" ExtrudeCGOSurfaceTube-DEBUG: exiting...\n" ENDFD; " ExtrudeCGOSurfaceTube-DEBUG: exiting...\n" ENDFD;
return ok; return ok;
} }
int ExtrudeCylindersToCGO(CExtrude * I, CGO * cgo, float tube_radius){ int ExtrudeCylindersToCGO(CExtrude * I, CGO * cgo, float tube_radius){
float *v1, *c1, midc[3], axis[3]; float *v1, *c1, midc[3], axis[3];
const float *alpha;
int a; int a;
unsigned int *i; unsigned int *i;
int ok = true; int ok = true;
PRINTFD(I->G, FB_Extrude) PRINTFD(I->G, FB_Extrude)
" ExtrudeCylindersToCGO-DEBUG: entered.\n" ENDFD; " ExtrudeCylindersToCGO-DEBUG: entered.\n" ENDFD;
v1 = I->p + 3; v1 = I->p + 3;
c1 = I->c + 3; c1 = I->c + 3;
alpha = I->alpha + 1;
i = I->i + 1; i = I->i + 1;
int cap = (cCylShaderBothCapsRound | cCylShaderInterpColor); int cap = (cCylShaderBothCapsRound | cCylShaderInterpColor);
for(a = 1; a < I->N; a++) { for(a = 1; a < I->N; a++) {
average3f(c1-3, c1, midc); average3f(c1-3, c1, midc);
ok &= CGOPickColor(cgo, *(i-1), cPickableAtom); ok &= CGOPickColor(cgo, *(i-1), cPickableAtom);
subtract3f(v1, v1-3, axis); subtract3f(v1, v1-3, axis);
CGOColorv(cgo, c1-3); CGOColorv(cgo, c1-3);
CGOAlpha(cgo, *(alpha-1));
Pickable pickcolor2 = { *i, cPickableAtom }; Pickable pickcolor2 = { *i, cPickableAtom };
cgo->add<cgo::draw::shadercylinder2ndcolor>(cgo, v1-3, axis, tube_radius, ca p, c1, &pickcolor2); cgo->add<cgo::draw::shadercylinder2ndcolor>(cgo, v1-3, axis, tube_radius, ca p, c1, &pickcolor2);
v1 += 3; v1 += 3;
c1 += 3; c1 += 3;
alpha++;
i++; i++;
cap = cCylShaderCap2Round | cCylShaderInterpColor; cap = cCylShaderCap2Round | cCylShaderInterpColor;
} }
if (ok) if (ok)
ok &= CGOPickColor(cgo, 0, cPickableNoPick); ok &= CGOPickColor(cgo, 0, cPickableNoPick);
PRINTFD(I->G, FB_Extrude) PRINTFD(I->G, FB_Extrude)
" ExtrudeCylindersToCGO-DEBUG: exiting...\n" ENDFD; " ExtrudeCylindersToCGO-DEBUG: exiting...\n" ENDFD;
return ok; return ok;
} }
int ExtrudeCGOSurfaceVariableTube(CExtrude * I, CGO * cgo, int cap) int ExtrudeCGOSurfaceVariableTube(CExtrude * I, CGO * cgo, int cap)
{ {
int a, b; int a, b;
unsigned int *i; unsigned int *i;
float *v; float *v;
float *n; float *n;
float *c; float *c;
const float *alpha;
float *sv, *sn, *tv, *tn, *tv1, *tn1, *TV = NULL, *TN = NULL, *AN = NULL, *an; float *sv, *sn, *tv, *tn, *tv1, *tn1, *TV = NULL, *TN = NULL, *AN = NULL, *an;
float v0[3]; float v0[3];
float *sf; /* PUTTY: scale factor from ExtrudeMakeSausLUT() */ float *sf; /* PUTTY: scale factor from ExtrudeMakeSausLUT() */
int ok = true; int ok = true;
PRINTFD(I->G, FB_Extrude) PRINTFD(I->G, FB_Extrude)
" ExtrudeCGOSurfaceTube-DEBUG: entered.\n" ENDFD; " ExtrudeCGOSurfaceTube-DEBUG: entered.\n" ENDFD;
if(I->N && I->Ns) { if(I->N && I->Ns) {
TV = Alloc(float, 3 * (I->Ns + 1) * I->N); TV = Alloc(float, 3 * (I->Ns + 1) * I->N);
skipping to change at line 1214 skipping to change at line 1235
tv1 = TV + 3 * I->N; tv1 = TV + 3 * I->N;
tn1 = TN + 3 * I->N; tn1 = TN + 3 * I->N;
for(b = 0; b < I->Ns; b++) { for(b = 0; b < I->Ns; b++) {
if(SettingGetGlobal_i(I->G, cSetting_cartoon_debug) < 1.5) if(SettingGetGlobal_i(I->G, cSetting_cartoon_debug) < 1.5)
CGOBegin(cgo, GL_TRIANGLE_STRIP); CGOBegin(cgo, GL_TRIANGLE_STRIP);
else { else {
CGOBegin(cgo, GL_LINE_STRIP); CGOBegin(cgo, GL_LINE_STRIP);
} }
c = I->c; c = I->c;
alpha = I->alpha;
i = I->i; i = I->i;
for(a = 0; a < I->N; a++) { for(a = 0; a < I->N; a++) {
CGOColorv(cgo, c); CGOColorv(cgo, c);
CGOAlpha(cgo, *alpha);
CGOPickColor(cgo, *i, cPickableAtom); CGOPickColor(cgo, *i, cPickableAtom);
CGONormalv(cgo, tn); CGONormalv(cgo, tn);
CGOVertexv(cgo, tv); CGOVertexv(cgo, tv);
tn += 3; tn += 3;
tv += 3; tv += 3;
CGONormalv(cgo, tn1); CGONormalv(cgo, tn1);
CGOVertexv(cgo, tv1); CGOVertexv(cgo, tv1);
tn1 += 3; tn1 += 3;
tv1 += 3; tv1 += 3;
c += 3; c += 3;
alpha++;
i++; i++;
} }
CGOEnd(cgo); CGOEnd(cgo);
CGOPickColor(cgo, -1, cPickableNoPick); CGOPickColor(cgo, -1, cPickableNoPick);
} }
if(ok && SettingGetGlobal_i(I->G, cSetting_cartoon_debug) > 3.5) { if(ok && SettingGetGlobal_i(I->G, cSetting_cartoon_debug) > 3.5) {
tv = TV; tv = TV;
tn = TN; tn = TN;
tv1 = TV + 3 * I->N; tv1 = TV + 3 * I->N;
tn1 = TN + 3 * I->N; tn1 = TN + 3 * I->N;
for(b = 0; b < I->Ns; b++) { for(b = 0; b < I->Ns; b++) {
float vv[3]; float vv[3];
CGOBegin(cgo, GL_LINES); CGOBegin(cgo, GL_LINES);
c = I->c; c = I->c;
alpha = I->alpha;
i = I->i; i = I->i;
for(a = 0; a < I->N; a++) { for(a = 0; a < I->N; a++) {
CGOColorv(cgo, c); CGOColorv(cgo, c);
CGOAlpha(cgo, *alpha);
copy3f(tn, vv); copy3f(tn, vv);
scale3f(vv, 0.3F, vv); scale3f(vv, 0.3F, vv);
add3f(vv, tv, vv); add3f(vv, tv, vv);
CGONormalv(cgo, tn); CGONormalv(cgo, tn);
CGOVertexv(cgo, tv); CGOVertexv(cgo, tv);
CGOVertexv(cgo, vv); CGOVertexv(cgo, vv);
tn += 3; tn += 3;
tv += 3; tv += 3;
copy3f(tn1, vv); copy3f(tn1, vv);
scale3f(vv, 0.3F, vv); scale3f(vv, 0.3F, vv);
add3f(vv, tv1, vv); add3f(vv, tv1, vv);
CGONormalv(cgo, tn1); CGONormalv(cgo, tn1);
CGOVertexv(cgo, tv1); CGOVertexv(cgo, tv1);
CGOVertexv(cgo, vv); CGOVertexv(cgo, vv);
tn1 += 3; tn1 += 3;
tv1 += 3; tv1 += 3;
c += 3; c += 3;
alpha++;
i++; i++;
} }
CGOEnd(cgo); CGOEnd(cgo);
} }
} }
if(ok && cap) { if(ok && cap) {
n = I->n; n = I->n;
v = I->p; v = I->p;
skipping to change at line 1294 skipping to change at line 1321
*(tv + 2) *= *sf; *(tv + 2) *= *sf;
add3f(v, tv, tv); add3f(v, tv, tv);
sv += 3; sv += 3;
tv += 3; tv += 3;
} }
CGOBegin(cgo, GL_TRIANGLE_FAN); CGOBegin(cgo, GL_TRIANGLE_FAN);
copy3f(I->n, v0); copy3f(I->n, v0);
invert3f(v0); invert3f(v0);
CGOColorv(cgo, I->c); CGOColorv(cgo, I->c);
CGOAlpha(cgo, I->alpha[0]);
CGOPickColor(cgo, I->i[0], cPickableAtom); CGOPickColor(cgo, I->i[0], cPickableAtom);
CGONormalv(cgo, v0); CGONormalv(cgo, v0);
if (ok) { if (ok) {
CGOVertexv(cgo, v); CGOVertexv(cgo, v);
/* trace shape */ /* trace shape */
CGOVertexv(cgo, I->tv); CGOVertexv(cgo, I->tv);
for(b = I->Ns - 1; b >= 0; b--) { for(b = I->Ns - 1; b >= 0; b--) {
CGOVertexv(cgo, I->tv + b * 3); CGOVertexv(cgo, I->tv + b * 3);
} }
CGOEnd(cgo); CGOEnd(cgo);
skipping to change at line 1324 skipping to change at line 1352
*(tv + 1) *= *(sf); *(tv + 1) *= *(sf);
*(tv + 2) *= *(sf); *(tv + 2) *= *(sf);
add3f(v, tv, tv); add3f(v, tv, tv);
sv += 3; sv += 3;
tv += 3; tv += 3;
} }
CGOBegin(cgo, GL_TRIANGLE_FAN); CGOBegin(cgo, GL_TRIANGLE_FAN);
CGOColorv(cgo, I->c + 3 * (I->N - 1)); CGOColorv(cgo, I->c + 3 * (I->N - 1));
CGOAlpha(cgo, I->alpha[I->N - 1]);
CGOPickColor(cgo, I->i[I->N - 1], cPickableAtom); CGOPickColor(cgo, I->i[I->N - 1], cPickableAtom);
CGONormalv(cgo, n); CGONormalv(cgo, n);
CGOVertexv(cgo, v); CGOVertexv(cgo, v);
/* trace shape */ /* trace shape */
for(b = 0; b < I->Ns; b++) { for(b = 0; b < I->Ns; b++) {
CGOVertexv(cgo, I->tv + b * 3); CGOVertexv(cgo, I->tv + b * 3);
} }
CGOVertexv(cgo, I->tv); CGOVertexv(cgo, I->tv);
CGOEnd(cgo); CGOEnd(cgo);
} }
skipping to change at line 1353 skipping to change at line 1382
return ok; return ok;
} }
int ExtrudeCGOSurfacePolygon(CExtrude * I, CGO * cgo, int cap, const float *colo r_override) int ExtrudeCGOSurfacePolygon(CExtrude * I, CGO * cgo, int cap, const float *colo r_override)
{ {
int a, b; int a, b;
unsigned int *i; unsigned int *i;
float *v; float *v;
float *n; float *n;
float *c; float *c;
const float *alpha;
float *sv, *sn, *tv, *tn, *tv1, *tn1, *TV = NULL, *TN = NULL; float *sv, *sn, *tv, *tn, *tv1, *tn1, *TV = NULL, *TN = NULL;
float v0[3]; float v0[3];
int ok = true; int ok = true;
PRINTFD(I->G, FB_Extrude) PRINTFD(I->G, FB_Extrude)
" ExtrudeCGOSurfacePolygon-DEBUG: entered.\n" ENDFD; " ExtrudeCGOSurfacePolygon-DEBUG: entered.\n" ENDFD;
if(I->N && I->Ns) { if(I->N && I->Ns) {
TV = Alloc(float, 3 * (I->Ns + 1) * I->N); TV = Alloc(float, 3 * (I->Ns + 1) * I->N);
skipping to change at line 1413 skipping to change at line 1443
} }
for(b = 0; ok && b < I->Ns; b += 2) { for(b = 0; ok && b < I->Ns; b += 2) {
if(SettingGetGlobal_i(I->G, cSetting_cartoon_debug) < 1.5) if(SettingGetGlobal_i(I->G, cSetting_cartoon_debug) < 1.5)
ok &= CGOBegin(cgo, GL_TRIANGLE_STRIP); ok &= CGOBegin(cgo, GL_TRIANGLE_STRIP);
else { else {
ok &= CGOBegin(cgo, GL_LINE_STRIP); ok &= CGOBegin(cgo, GL_LINE_STRIP);
} }
if(ok && color_override) if(ok && color_override)
ok &= CGOColorv(cgo, color_override); ok &= CGOColorv(cgo, color_override);
c = I->c; c = I->c;
alpha = I->alpha;
i = I->i; i = I->i;
for(a = 0; ok && a < I->N; a++) { for(a = 0; ok && a < I->N; a++) {
if(!color_override) if(!color_override)
ok &= CGOColorv(cgo, c); ok &= CGOColorv(cgo, c);
if (ok){
ok &= CGOAlpha(cgo, *alpha);
}
if (ok) if (ok)
ok &= CGOPickColor(cgo, *i, cPickableAtom); ok &= CGOPickColor(cgo, *i, cPickableAtom);
if (ok) if (ok)
ok &= CGONormalv(cgo, tn); ok &= CGONormalv(cgo, tn);
if (ok) if (ok)
ok &= CGOVertexv(cgo, tv); ok &= CGOVertexv(cgo, tv);
tn += 3; tn += 3;
tv += 3; tv += 3;
if (ok) if (ok)
ok &= CGONormalv(cgo, tn1); ok &= CGONormalv(cgo, tn1);
if (ok) if (ok)
ok &= CGOVertexv(cgo, tv1); ok &= CGOVertexv(cgo, tv1);
tn1 += 3; tn1 += 3;
tv1 += 3; tv1 += 3;
c += 3; c += 3;
alpha++;
i++; i++;
} }
tv += 3 * I->N; tv += 3 * I->N;
tn += 3 * I->N; tn += 3 * I->N;
tv1 += 3 * I->N; tv1 += 3 * I->N;
tn1 += 3 * I->N; tn1 += 3 * I->N;
if (ok) if (ok)
ok &= CGOEnd(cgo); ok &= CGOEnd(cgo);
if (ok) if (ok)
ok &= CGOPickColor(cgo, -1, cPickableNoPick); ok &= CGOPickColor(cgo, -1, cPickableNoPick);
skipping to change at line 1469 skipping to change at line 1504
tv += 3; tv += 3;
} }
} }
if (ok) if (ok)
ok &= CGOBegin(cgo, GL_TRIANGLE_FAN); ok &= CGOBegin(cgo, GL_TRIANGLE_FAN);
if (ok){ if (ok){
copy3f(I->n, v0); copy3f(I->n, v0);
invert3f(v0); invert3f(v0);
if(!color_override) if(!color_override)
ok &= CGOColorv(cgo, I->c); ok &= CGOColorv(cgo, I->c);
if (ok){
ok &= CGOAlpha(cgo, I->alpha[0]);
}
if (ok) if (ok)
ok &= CGOPickColor(cgo, I->i[0], cPickableAtom); ok &= CGOPickColor(cgo, I->i[0], cPickableAtom);
if (ok) if (ok)
ok &= CGONormalv(cgo, v0); ok &= CGONormalv(cgo, v0);
} }
if (ok) if (ok)
ok &= CGOVertexv(cgo, v); ok &= CGOVertexv(cgo, v);
/* trace shape */ /* trace shape */
if (ok) if (ok)
ok &= CGOVertexv(cgo, I->tv); ok &= CGOVertexv(cgo, I->tv);
skipping to change at line 1503 skipping to change at line 1541
transform33Tf3f(n, sv, tv); transform33Tf3f(n, sv, tv);
add3f(v, tv, tv); add3f(v, tv, tv);
sv += 3; sv += 3;
tv += 3; tv += 3;
} }
} }
if (ok) if (ok)
ok &= CGOBegin(cgo, GL_TRIANGLE_FAN); ok &= CGOBegin(cgo, GL_TRIANGLE_FAN);
if(ok && !color_override) if(ok && !color_override)
ok &= CGOColorv(cgo, I->c + 3 * (I->N - 1)); ok &= CGOColorv(cgo, I->c + 3 * (I->N - 1));
if (ok){
ok &= CGOAlpha(cgo, I->alpha[I->N - 1]);
}
if (ok) if (ok)
ok &= CGOPickColor(cgo, I->i[I->N - 1], cPickableAtom); ok &= CGOPickColor(cgo, I->i[I->N - 1], cPickableAtom);
if (ok) if (ok)
ok &= CGONormalv(cgo, n); ok &= CGONormalv(cgo, n);
if (ok) if (ok)
ok &= CGOVertexv(cgo, v); ok &= CGOVertexv(cgo, v);
/* trace shape */ /* trace shape */
for(b = 0; ok && b < I->Ns; b++) { for(b = 0; ok && b < I->Ns; b++) {
ok &= CGOVertexv(cgo, I->tv + b * 3); ok &= CGOVertexv(cgo, I->tv + b * 3);
} }
skipping to change at line 1537 skipping to change at line 1578
} }
int ExtrudeCGOSurfacePolygonTaper(CExtrude * I, CGO * cgo, int sampling, int ExtrudeCGOSurfacePolygonTaper(CExtrude * I, CGO * cgo, int sampling,
const float *color_override) const float *color_override)
{ {
int a, b; int a, b;
unsigned int *i; unsigned int *i;
float *v; float *v;
float *n; float *n;
float *c; float *c;
const float *alpha;
float *sv, *sn, *tv, *tn, *tv1, *tn1, *TV = NULL, *TN = NULL; float *sv, *sn, *tv, *tn, *tv1, *tn1, *TV = NULL, *TN = NULL;
float s0[3]; float s0[3];
float f; float f;
int subN; int subN;
int ok = true; int ok = true;
subN = I->N - sampling; subN = I->N - sampling;
PRINTFD(I->G, FB_Extrude) PRINTFD(I->G, FB_Extrude)
" ExtrudeCGOSurfacePolygonTaper-DEBUG: entered.\n" ENDFD; " ExtrudeCGOSurfacePolygonTaper-DEBUG: entered.\n" ENDFD;
skipping to change at line 1626 skipping to change at line 1668
if (ok){ if (ok){
if(SettingGetGlobal_i(I->G, cSetting_cartoon_debug) < 1.5) if(SettingGetGlobal_i(I->G, cSetting_cartoon_debug) < 1.5)
ok &= CGOBegin(cgo, GL_TRIANGLE_STRIP); ok &= CGOBegin(cgo, GL_TRIANGLE_STRIP);
else { else {
ok &= CGOBegin(cgo, GL_LINE_STRIP); ok &= CGOBegin(cgo, GL_LINE_STRIP);
} }
} }
if(ok && color_override) if(ok && color_override)
ok &= CGOColorv(cgo, color_override); ok &= CGOColorv(cgo, color_override);
c = I->c; c = I->c;
alpha = I->alpha;
i = I->i; i = I->i;
for(a = 0; ok && a < I->N; a++) { for(a = 0; ok && a < I->N; a++) {
if(!color_override) if(!color_override)
ok &= CGOColorv(cgo, c); ok &= CGOColorv(cgo, c);
if (ok){
ok &= CGOAlpha(cgo, *alpha);
}
if (ok) if (ok)
ok &= CGOPickColor(cgo, *i, cPickableAtom); ok &= CGOPickColor(cgo, *i, cPickableAtom);
if (ok) if (ok)
ok &= CGONormalv(cgo, tn); ok &= CGONormalv(cgo, tn);
if (ok) if (ok)
ok &= CGOVertexv(cgo, tv); ok &= CGOVertexv(cgo, tv);
tn += 3; tn += 3;
tv += 3; tv += 3;
if (ok) if (ok)
ok &= CGONormalv(cgo, tn1); ok &= CGONormalv(cgo, tn1);
if (ok) if (ok)
ok &= CGOVertexv(cgo, tv1); ok &= CGOVertexv(cgo, tv1);
tn1 += 3; tn1 += 3;
tv1 += 3; tv1 += 3;
c += 3; c += 3;
alpha++;
i++; i++;
} }
if (ok){ if (ok){
tv += 3 * I->N; tv += 3 * I->N;
tn += 3 * I->N; tn += 3 * I->N;
tv1 += 3 * I->N; tv1 += 3 * I->N;
tn1 += 3 * I->N; tn1 += 3 * I->N;
CGOEnd(cgo); CGOEnd(cgo);
CGOPickColor(cgo, -1, cPickableNoPick); CGOPickColor(cgo, -1, cPickableNoPick);
} }
skipping to change at line 1673 skipping to change at line 1720
return ok; return ok;
} }
int ExtrudeCGOSurfaceStrand(CExtrude * I, CGO * cgo, int sampling, const float * color_override) int ExtrudeCGOSurfaceStrand(CExtrude * I, CGO * cgo, int sampling, const float * color_override)
{ {
int a, b; int a, b;
unsigned int *i; unsigned int *i;
float *v; float *v;
float *n; float *n;
float *c; float *c;
const float *alpha;
float *sv, *sn, *tv, *tn, *tv1, *tn1, *TV = NULL, *TN = NULL; float *sv, *sn, *tv, *tn, *tv1, *tn1, *TV = NULL, *TN = NULL;
float v0[3], n0[3], s0[3], z[3] = { 1.0, 0.0, 1.0 }; float v0[3], n0[3], s0[3], z[3] = { 1.0, 0.0, 1.0 };
int subN; int subN;
int ok = true; int ok = true;
subN = I->N - sampling; subN = I->N - sampling;
PRINTFD(I->G, FB_Extrude) PRINTFD(I->G, FB_Extrude)
" ExtrudeCGOSurfaceStrand-DEBUG: entered.\n" ENDFD; " ExtrudeCGOSurfaceStrand-DEBUG: entered.\n" ENDFD;
if(I->N && I->Ns) { if(I->N && I->Ns) {
skipping to change at line 1736 skipping to change at line 1784
tn1 = TN + 3 * I->N; tn1 = TN + 3 * I->N;
} }
for(b = 0; ok && b < I->Ns; b += 2) { for(b = 0; ok && b < I->Ns; b += 2) {
if(SettingGetGlobal_i(I->G, cSetting_cartoon_debug) < 1.5) if(SettingGetGlobal_i(I->G, cSetting_cartoon_debug) < 1.5)
ok &= CGOBegin(cgo, GL_TRIANGLE_STRIP); ok &= CGOBegin(cgo, GL_TRIANGLE_STRIP);
else { else {
ok &= CGOBegin(cgo, GL_LINE_STRIP); ok &= CGOBegin(cgo, GL_LINE_STRIP);
} }
c = I->c; c = I->c;
alpha = I->alpha;
i = I->i; i = I->i;
for(a = 0; ok && a < I->N; a++) { for(a = 0; ok && a < I->N; a++) {
if(a < subN) { if(a < subN) {
if(color_override && ((b == 2) || (b == 3) || (b == 6) || (b == 7))) if(color_override && ((b == 2) || (b == 3) || (b == 6) || (b == 7)))
ok &= CGOColorv(cgo, color_override); ok &= CGOColorv(cgo, color_override);
else else
ok &= CGOColorv(cgo, c); ok &= CGOColorv(cgo, c);
if (ok){
ok &= CGOAlpha(cgo, *alpha);
}
if (ok) if (ok)
ok &= CGOPickColor(cgo, *i, cPickableAtom); ok &= CGOPickColor(cgo, *i, cPickableAtom);
if (ok) if (ok)
ok &= CGONormalv(cgo, tn); ok &= CGONormalv(cgo, tn);
if (ok) if (ok)
ok &= CGOVertexv(cgo, tv); ok &= CGOVertexv(cgo, tv);
} }
tn += 3; tn += 3;
tv += 3; tv += 3;
if(ok && a < subN) { if(ok && a < subN) {
ok &= CGONormalv(cgo, tn1); ok &= CGONormalv(cgo, tn1);
if (ok) if (ok)
ok &= CGOVertexv(cgo, tv1); ok &= CGOVertexv(cgo, tv1);
} }
tn1 += 3; tn1 += 3;
tv1 += 3; tv1 += 3;
c += 3; c += 3;
alpha++;
i++; i++;
} }
tv += 3 * I->N; tv += 3 * I->N;
tn += 3 * I->N; tn += 3 * I->N;
tv1 += 3 * I->N; tv1 += 3 * I->N;
tn1 += 3 * I->N; tn1 += 3 * I->N;
if (ok) if (ok)
ok &= CGOEnd(cgo); ok &= CGOEnd(cgo);
if (ok) if (ok)
ok &= CGOPickColor(cgo, -1, cPickableNoPick); ok &= CGOPickColor(cgo, -1, cPickableNoPick);
skipping to change at line 1793 skipping to change at line 1846
tv += 3; tv += 3;
} }
copy3f(I->n, v0); copy3f(I->n, v0);
invert3f(v0); invert3f(v0);
if (ok){ if (ok){
if(color_override) if(color_override)
ok &= CGOColorv(cgo, color_override); ok &= CGOColorv(cgo, color_override);
else else
ok &= CGOColorv(cgo, I->c); ok &= CGOColorv(cgo, I->c);
}
if(ok){
ok &= CGOAlpha(cgo, I->alpha[0]);
} }
if (ok) if (ok)
ok &= CGOPickColor(cgo, I->i[0], cPickableAtom); ok &= CGOPickColor(cgo, I->i[0], cPickableAtom);
if (ok) if (ok)
ok &= CGOBegin(cgo, GL_TRIANGLE_STRIP); ok &= CGOBegin(cgo, GL_TRIANGLE_STRIP);
if (ok) if (ok)
ok &= CGONormalv(cgo, v0); ok &= CGONormalv(cgo, v0);
ok &= CGOVertexv(cgo, I->tv + 6 * 3); ok &= CGOVertexv(cgo, I->tv + 6 * 3);
skipping to change at line 1864 skipping to change at line 1920
for(b = 0; ok && b < I->Ns; b += 2) { for(b = 0; ok && b < I->Ns; b += 2) {
if (ok){ if (ok){
if(SettingGetGlobal_i(I->G, cSetting_cartoon_debug) < 1.5) if(SettingGetGlobal_i(I->G, cSetting_cartoon_debug) < 1.5)
ok &= CGOBegin(cgo, GL_TRIANGLE_STRIP); ok &= CGOBegin(cgo, GL_TRIANGLE_STRIP);
else { else {
ok &= CGOBegin(cgo, GL_LINE_STRIP); ok &= CGOBegin(cgo, GL_LINE_STRIP);
} }
} }
c = I->c; c = I->c;
alpha = I->alpha;
i = I->i; i = I->i;
for(a = 0; ok && a < I->N; a++) { for(a = 0; ok && a < I->N; a++) {
if(a >= (subN - 1)) { if(a >= (subN - 1)) {
if(color_override && ((b == 2) || (b == 3) || (b == 6) || (b == 7))) if(color_override && ((b == 2) || (b == 3) || (b == 6) || (b == 7)))
ok &= CGOColorv(cgo, color_override); ok &= CGOColorv(cgo, color_override);
else else
ok &= CGOColorv(cgo, c); ok &= CGOColorv(cgo, c);
if (ok){
ok &= CGOAlpha(cgo, *alpha);
}
if (ok) if (ok)
ok &= CGOPickColor(cgo, *i, cPickableAtom); ok &= CGOPickColor(cgo, *i, cPickableAtom);
if (ok) if (ok)
ok &= CGONormalv(cgo, tn); ok &= CGONormalv(cgo, tn);
if (ok) if (ok)
ok &= CGOVertexv(cgo, tv); ok &= CGOVertexv(cgo, tv);
} }
tn += 3; tn += 3;
tv += 3; tv += 3;
if(ok && a >= (subN - 1)) { if(ok && a >= (subN - 1)) {
ok &= CGONormalv(cgo, tn1); ok &= CGONormalv(cgo, tn1);
if (ok) if (ok)
ok &= CGOVertexv(cgo, tv1); ok &= CGOVertexv(cgo, tv1);
} }
tn1 += 3; tn1 += 3;
tv1 += 3; tv1 += 3;
c += 3; c += 3;
alpha++;
i++; i++;
} }
tv += 3 * I->N; tv += 3 * I->N;
tn += 3 * I->N; tn += 3 * I->N;
tv1 += 3 * I->N; tv1 += 3 * I->N;
tn1 += 3 * I->N; tn1 += 3 * I->N;
if (ok) if (ok)
ok &= CGOEnd(cgo); ok &= CGOEnd(cgo);
if (ok) if (ok)
ok &= CGOPickColor(cgo, -1, cPickableNoPick); ok &= CGOPickColor(cgo, -1, cPickableNoPick);
skipping to change at line 1925 skipping to change at line 1986
// Back end/flat surface of the arrow, // Back end/flat surface of the arrow,
// now split into two pieces, one for each side // now split into two pieces, one for each side
copy3f(n, v0); copy3f(n, v0);
invert3f(v0); invert3f(v0);
if (ok){ if (ok){
if(color_override) if(color_override)
ok &= CGOColorv(cgo, color_override); ok &= CGOColorv(cgo, color_override);
else else
ok &= CGOColorv(cgo, I->c + 3 * (subN - 1)); ok &= CGOColorv(cgo, I->c + 3 * (subN - 1));
} }
if (ok){
ok &= CGOAlpha(cgo, I->alpha[(subN - 1)]);
}
if (ok) if (ok)
ok &= CGOPickColor(cgo, I->i[(subN - 1)], cPickableAtom); ok &= CGOPickColor(cgo, I->i[(subN - 1)], cPickableAtom);
// draw first side // draw first side
tv = I->tv; tv = I->tv;
if (ok) if (ok)
ok &= CGOBegin(cgo, GL_TRIANGLE_STRIP); ok &= CGOBegin(cgo, GL_TRIANGLE_STRIP);
if (ok) if (ok)
ok &= CGONormalv(cgo, v0); ok &= CGONormalv(cgo, v0);
ok &= CGOVertexv(cgo, I->tv + 6 * 3); ok &= CGOVertexv(cgo, I->tv + 6 * 3);
skipping to change at line 2165 skipping to change at line 2229
} }
int ExtrudeAllocPointsNormalsColors(CExtrude * I, int n) int ExtrudeAllocPointsNormalsColors(CExtrude * I, int n)
{ {
int ok = true; int ok = true;
if(I->N < n) { if(I->N < n) {
/* reset */ /* reset */
FreeP(I->p); FreeP(I->p);
FreeP(I->n); FreeP(I->n);
FreeP(I->c); FreeP(I->c);
FreeP(I->alpha);
FreeP(I->i); FreeP(I->i);
FreeP(I->sf); /* PUTTY */ FreeP(I->sf); /* PUTTY */
I->p = Alloc(float, 3 * (n + 1)); I->p = Alloc(float, 3 * (n + 1));
CHECKOK(ok, I->p); CHECKOK(ok, I->p);
if (ok) if (ok)
I->n = Alloc(float, 9 * (n + 1)); I->n = Alloc(float, 9 * (n + 1));
CHECKOK(ok, I->n); CHECKOK(ok, I->n);
if (ok) if (ok)
I->c = Alloc(float, 3 * (n + 1)); I->c = Alloc(float, 3 * (n + 1));
CHECKOK(ok, I->c); CHECKOK(ok, I->c);
if (ok) if (ok)
I->alpha = Alloc(float, n + 1);
CHECKOK(ok, I->alpha);
if (ok)
I->i = Alloc(unsigned int, 3 * (n + 1)); I->i = Alloc(unsigned int, 3 * (n + 1));
CHECKOK(ok, I->i); CHECKOK(ok, I->i);
if (ok) if (ok)
I->sf = Alloc(float, n + 1); /* PUTTY: scale factors */ I->sf = Alloc(float, n + 1); /* PUTTY: scale factors */
CHECKOK(ok, I->sf); CHECKOK(ok, I->sf);
if (!ok){ if (!ok){
FreeP(I->p); FreeP(I->p);
FreeP(I->n); FreeP(I->n);
FreeP(I->c); FreeP(I->c);
FreeP(I->alpha);
FreeP(I->i); FreeP(I->i);
FreeP(I->sf); FreeP(I->sf);
I->p = NULL;
I->n = NULL;
I->c = NULL;
I->i = NULL;
I->sf = NULL;
} }
} }
I->N = n; I->N = n;
return ok; return ok;
} }
void ExtrudeFree(CExtrude * I) void ExtrudeFree(CExtrude * I)
{ {
FreeP(I->p); FreeP(I->p);
FreeP(I->n); FreeP(I->n);
FreeP(I->c); FreeP(I->c);
FreeP(I->alpha);
FreeP(I->tn); FreeP(I->tn);
FreeP(I->tv); FreeP(I->tv);
FreeP(I->sn); FreeP(I->sn);
FreeP(I->sv); FreeP(I->sv);
FreeP(I->i); FreeP(I->i);
FreeP(I->sf); FreeP(I->sf);
OOFreeP(I); OOFreeP(I);
} }
 End of changes. 47 change blocks. 
5 lines changed or deleted 70 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)