[iortcw] 126/497: All: Rend2: Reimplement MD3 tangent space calculation

2017-09-08 Thread Simon McVittie
This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag 1.42d
in repository iortcw.

commit a0b5f69f747745dd3a86cdd8a8fa5ae59b1b7c4d
Author: m4n4t4...@gmail.com 

Date:   Wed May 28 23:11:43 2014 +

All: Rend2: Reimplement MD3 tangent space calculation
---
 MP/code/rend2/tr_init.c  |   2 -
 MP/code/rend2/tr_local.h |   6 +-
 MP/code/rend2/tr_main.c  |  36 ++--
 MP/code/rend2/tr_model.c | 148 +++
 SP/code/rend2/tr_init.c  |   2 -
 SP/code/rend2/tr_local.h |   6 +-
 SP/code/rend2/tr_main.c  |  36 ++--
 SP/code/rend2/tr_model.c | 146 ++
 8 files changed, 159 insertions(+), 223 deletions(-)

diff --git a/MP/code/rend2/tr_init.c b/MP/code/rend2/tr_init.c
index 3e1e72f..5b41d63 100644
--- a/MP/code/rend2/tr_init.c
+++ b/MP/code/rend2/tr_init.c
@@ -165,7 +165,6 @@ cvar_t  *r_baseNormalY;
 cvar_t  *r_baseParallax;
 cvar_t  *r_baseSpecular;
 cvar_t  *r_baseGloss;
-cvar_t  *r_recalcMD3Normals;
 cvar_t  *r_mergeLightmaps;
 cvar_t  *r_dlightMode;
 cvar_t  *r_pshadowDist;
@@ -1321,7 +1320,6 @@ void R_Register( void ) {
r_baseGloss = ri.Cvar_Get( "r_baseGloss", "0.3", CVAR_ARCHIVE | 
CVAR_LATCH );
r_dlightMode = ri.Cvar_Get( "r_dlightMode", "0", CVAR_ARCHIVE | 
CVAR_LATCH );
r_pshadowDist = ri.Cvar_Get( "r_pshadowDist", "128", CVAR_ARCHIVE );
-   r_recalcMD3Normals = ri.Cvar_Get( "r_recalcMD3Normals", "0", 
CVAR_ARCHIVE | CVAR_LATCH );
r_mergeLightmaps = ri.Cvar_Get( "r_mergeLightmaps", "1", CVAR_ARCHIVE | 
CVAR_LATCH );
r_imageUpsample = ri.Cvar_Get( "r_imageUpsample", "0", CVAR_ARCHIVE | 
CVAR_LATCH );
r_imageUpsampleMaxSize = ri.Cvar_Get( "r_imageUpsampleMaxSize", "1024", 
CVAR_ARCHIVE | CVAR_LATCH );
diff --git a/MP/code/rend2/tr_local.h b/MP/code/rend2/tr_local.h
index 9b59b71..09ddc30 100644
--- a/MP/code/rend2/tr_local.h
+++ b/MP/code/rend2/tr_local.h
@@ -2000,7 +2000,6 @@ extern  cvar_t  *r_baseSpecular;
 extern  cvar_t  *r_baseGloss;
 extern  cvar_t  *r_dlightMode;
 extern  cvar_t  *r_pshadowDist;
-extern  cvar_t  *r_recalcMD3Normals;
 extern  cvar_t  *r_mergeLightmaps;
 extern  cvar_t  *r_imageUpsample;
 extern  cvar_t  *r_imageUpsampleMaxSize;
@@ -2076,8 +2075,9 @@ void R_DecomposeSort( unsigned sort, int *entityNum, 
shader_t **shader,
 void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, 
int fogIndex, int dlightMap, int pshadowMap, int 
cubemap );
 
-void R_CalcTangentSpace(vec3_t tangent, vec3_t bitangent, vec3_t normal,
-const vec3_t v0, const vec3_t v1, const vec3_t v2, 
const vec2_t t0, const vec2_t t1, const vec2_t t2);
+void R_CalcTexDirs(vec3_t sdir, vec3_t tdir, const vec3_t v1, const vec3_t v2,
+  const vec3_t v3, const vec2_t w1, const 
vec2_t w2, const vec2_t w3);
+void R_CalcTbnFromNormalAndTexDirs(vec3_t tangent, vec3_t bitangent, vec3_t 
normal, vec3_t sdir, vec3_t tdir);
 qboolean R_CalcTangentVectors(srfVert_t * dv[3]);
 
 #define CULL_IN 0   // completely unclipped
diff --git a/MP/code/rend2/tr_main.c b/MP/code/rend2/tr_main.c
index f473875..881c031 100644
--- a/MP/code/rend2/tr_main.c
+++ b/MP/code/rend2/tr_main.c
@@ -464,13 +464,11 @@ void R_CalcTangentSpaceFast(vec3_t tangent, vec3_t 
bitangent, vec3_t normal,
 /*
 http://www.terathon.com/code/tangent.html
 */
-void R_CalcTBN(vec3_t tangent, vec3_t bitangent, vec3_t normal,
-   const vec3_t v1, const vec3_t 
v2, const vec3_t v3, const vec2_t w1, const vec2_t w2, const vec2_t w3)
+void R_CalcTexDirs(vec3_t sdir, vec3_t tdir, const vec3_t v1, const vec3_t v2,
+  const vec3_t v3, const vec2_t w1, const 
vec2_t w2, const vec2_t w3)
 {
-   vec3_t  u, v;
float   x1, x2, y1, y2, z1, z2;
-   float   s1, s2, t1, t2;
-   float   r, dot;
+   float   s1, s2, t1, t2, r;
 
x1 = v2[0] - v1[0];
x2 = v3[0] - v1[0];
@@ -486,24 +484,28 @@ void R_CalcTBN(vec3_t tangent, vec3_t bitangent, vec3_t 
normal,
 
r = 1.0f / (s1 * t2 - s2 * t1);
 
-   VectorSet(tangent, (t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r, 
(t2 * z1 - t1 * z2) * r);
-   VectorSet(bitangent, (s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, 
(s1 * z2 - s2 * z1) * r);
+   VectorSet(sdir, (t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r, (t2 * 
z1 - t1 * z2) * r);
+   VectorSet(tdir, (s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, (s1 * 
z2 - s2 * z1) * r);
+}
 
-   // compute the face normal based on vertex points
-   VectorSubtract(v3, v1, u);
-   VectorSubtract(v2, v1, v);
-   CrossProduct(u, v, normal);
 
-   VectorNormalize(normal);
+void R_CalcTbnFromNormalAndTexDirs(vec3_t tangent, vec3_t bitangent, vec3_t 
normal, vec3_t sdir, vec3_t tdir)
+{
+  

[iortcw] 126/497: All: Rend2: Reimplement MD3 tangent space calculation

2016-09-21 Thread Simon McVittie
This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag 1.42d
in repository iortcw.

commit a0b5f69f747745dd3a86cdd8a8fa5ae59b1b7c4d
Author: m4n4t4...@gmail.com 

Date:   Wed May 28 23:11:43 2014 +

All: Rend2: Reimplement MD3 tangent space calculation
---
 MP/code/rend2/tr_init.c  |   2 -
 MP/code/rend2/tr_local.h |   6 +-
 MP/code/rend2/tr_main.c  |  36 ++--
 MP/code/rend2/tr_model.c | 148 +++
 SP/code/rend2/tr_init.c  |   2 -
 SP/code/rend2/tr_local.h |   6 +-
 SP/code/rend2/tr_main.c  |  36 ++--
 SP/code/rend2/tr_model.c | 146 ++
 8 files changed, 159 insertions(+), 223 deletions(-)

diff --git a/MP/code/rend2/tr_init.c b/MP/code/rend2/tr_init.c
index 3e1e72f..5b41d63 100644
--- a/MP/code/rend2/tr_init.c
+++ b/MP/code/rend2/tr_init.c
@@ -165,7 +165,6 @@ cvar_t  *r_baseNormalY;
 cvar_t  *r_baseParallax;
 cvar_t  *r_baseSpecular;
 cvar_t  *r_baseGloss;
-cvar_t  *r_recalcMD3Normals;
 cvar_t  *r_mergeLightmaps;
 cvar_t  *r_dlightMode;
 cvar_t  *r_pshadowDist;
@@ -1321,7 +1320,6 @@ void R_Register( void ) {
r_baseGloss = ri.Cvar_Get( "r_baseGloss", "0.3", CVAR_ARCHIVE | 
CVAR_LATCH );
r_dlightMode = ri.Cvar_Get( "r_dlightMode", "0", CVAR_ARCHIVE | 
CVAR_LATCH );
r_pshadowDist = ri.Cvar_Get( "r_pshadowDist", "128", CVAR_ARCHIVE );
-   r_recalcMD3Normals = ri.Cvar_Get( "r_recalcMD3Normals", "0", 
CVAR_ARCHIVE | CVAR_LATCH );
r_mergeLightmaps = ri.Cvar_Get( "r_mergeLightmaps", "1", CVAR_ARCHIVE | 
CVAR_LATCH );
r_imageUpsample = ri.Cvar_Get( "r_imageUpsample", "0", CVAR_ARCHIVE | 
CVAR_LATCH );
r_imageUpsampleMaxSize = ri.Cvar_Get( "r_imageUpsampleMaxSize", "1024", 
CVAR_ARCHIVE | CVAR_LATCH );
diff --git a/MP/code/rend2/tr_local.h b/MP/code/rend2/tr_local.h
index 9b59b71..09ddc30 100644
--- a/MP/code/rend2/tr_local.h
+++ b/MP/code/rend2/tr_local.h
@@ -2000,7 +2000,6 @@ extern  cvar_t  *r_baseSpecular;
 extern  cvar_t  *r_baseGloss;
 extern  cvar_t  *r_dlightMode;
 extern  cvar_t  *r_pshadowDist;
-extern  cvar_t  *r_recalcMD3Normals;
 extern  cvar_t  *r_mergeLightmaps;
 extern  cvar_t  *r_imageUpsample;
 extern  cvar_t  *r_imageUpsampleMaxSize;
@@ -2076,8 +2075,9 @@ void R_DecomposeSort( unsigned sort, int *entityNum, 
shader_t **shader,
 void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, 
int fogIndex, int dlightMap, int pshadowMap, int 
cubemap );
 
-void R_CalcTangentSpace(vec3_t tangent, vec3_t bitangent, vec3_t normal,
-const vec3_t v0, const vec3_t v1, const vec3_t v2, 
const vec2_t t0, const vec2_t t1, const vec2_t t2);
+void R_CalcTexDirs(vec3_t sdir, vec3_t tdir, const vec3_t v1, const vec3_t v2,
+  const vec3_t v3, const vec2_t w1, const 
vec2_t w2, const vec2_t w3);
+void R_CalcTbnFromNormalAndTexDirs(vec3_t tangent, vec3_t bitangent, vec3_t 
normal, vec3_t sdir, vec3_t tdir);
 qboolean R_CalcTangentVectors(srfVert_t * dv[3]);
 
 #define CULL_IN 0   // completely unclipped
diff --git a/MP/code/rend2/tr_main.c b/MP/code/rend2/tr_main.c
index f473875..881c031 100644
--- a/MP/code/rend2/tr_main.c
+++ b/MP/code/rend2/tr_main.c
@@ -464,13 +464,11 @@ void R_CalcTangentSpaceFast(vec3_t tangent, vec3_t 
bitangent, vec3_t normal,
 /*
 http://www.terathon.com/code/tangent.html
 */
-void R_CalcTBN(vec3_t tangent, vec3_t bitangent, vec3_t normal,
-   const vec3_t v1, const vec3_t 
v2, const vec3_t v3, const vec2_t w1, const vec2_t w2, const vec2_t w3)
+void R_CalcTexDirs(vec3_t sdir, vec3_t tdir, const vec3_t v1, const vec3_t v2,
+  const vec3_t v3, const vec2_t w1, const 
vec2_t w2, const vec2_t w3)
 {
-   vec3_t  u, v;
float   x1, x2, y1, y2, z1, z2;
-   float   s1, s2, t1, t2;
-   float   r, dot;
+   float   s1, s2, t1, t2, r;
 
x1 = v2[0] - v1[0];
x2 = v3[0] - v1[0];
@@ -486,24 +484,28 @@ void R_CalcTBN(vec3_t tangent, vec3_t bitangent, vec3_t 
normal,
 
r = 1.0f / (s1 * t2 - s2 * t1);
 
-   VectorSet(tangent, (t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r, 
(t2 * z1 - t1 * z2) * r);
-   VectorSet(bitangent, (s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, 
(s1 * z2 - s2 * z1) * r);
+   VectorSet(sdir, (t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r, (t2 * 
z1 - t1 * z2) * r);
+   VectorSet(tdir, (s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, (s1 * 
z2 - s2 * z1) * r);
+}
 
-   // compute the face normal based on vertex points
-   VectorSubtract(v3, v1, u);
-   VectorSubtract(v2, v1, v);
-   CrossProduct(u, v, normal);
 
-   VectorNormalize(normal);
+void R_CalcTbnFromNormalAndTexDirs(vec3_t tangent, vec3_t bitangent, vec3_t 
normal, vec3_t sdir, vec3_t tdir)
+{
+