2002-10-12 11:37:38 +00:00
|
|
|
#undef TEST_ACTIVE
|
|
|
|
|
//#define ACTIVE 1
|
|
|
|
|
/**
|
|
|
|
|
* blenlib/BLI_arithb.h mar 2001 Nzc
|
|
|
|
|
*
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
|
|
|
|
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version. The Blender
|
|
|
|
|
* Foundation also sells licenses for use in proprietary software under
|
|
|
|
|
* the Blender License. See http://www.blender.org/BL/ for information
|
|
|
|
|
* about this.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* The old math stuff from Ton. These will slowly phase out in favour
|
|
|
|
|
* of MTC calls. (or even MoTO :) )
|
|
|
|
|
* */
|
|
|
|
|
|
|
|
|
|
#ifndef BLI_ARITHB_H
|
|
|
|
|
#define BLI_ARITHB_H
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-03-19 20:04:25 +00:00
|
|
|
#ifndef M_PI
|
|
|
|
|
#define M_PI 3.14159265358979323846
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef M_PI_2
|
|
|
|
|
#define M_PI_2 1.57079632679489661923
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef M_SQRT2
|
|
|
|
|
#define M_SQRT2 1.41421356237309504880
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef M_SQRT1_2
|
|
|
|
|
#define M_SQRT1_2 0.70710678118654752440
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#define MAT4_UNITY {{ 1.0, 0.0, 0.0, 0.0},\
|
|
|
|
|
{ 0.0, 1.0, 0.0, 0.0},\
|
|
|
|
|
{ 0.0, 0.0, 1.0, 0.0},\
|
|
|
|
|
{ 0.0, 0.0, 0.0, 1.0}}
|
|
|
|
|
|
|
|
|
|
#define MAT3_UNITY {{ 1.0, 0.0, 0.0},\
|
|
|
|
|
{ 0.0, 1.0, 0.0},\
|
|
|
|
|
{ 0.0, 0.0, 1.0}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* matrix operations */
|
|
|
|
|
/* void Mat4MulMat4(float m1[][4], float m2[][4], float m3[][4]); */
|
|
|
|
|
/* void Mat3MulVecfl(float mat[][3], float *vec); */
|
|
|
|
|
/* or **mat, but it's the same */
|
|
|
|
|
/*void Mat3MulVecd(float mat[][3], double *vec); */
|
|
|
|
|
|
|
|
|
|
/* void Mat4MulVecfl(float mat[][4], float *vec); */
|
|
|
|
|
/* void Mat4MulSerie(float answ[][4], float m1[][4], float m2[][4], */
|
|
|
|
|
/* float m3[][4], float m4[][4], float m5[][4], */
|
|
|
|
|
/* float m6[][4], float m7[][4], float m8[][4]); */
|
|
|
|
|
/* int Mat4Invert(float inverse[][4], float mat[][4]); */
|
|
|
|
|
|
|
|
|
|
/* m2 to m1 */
|
|
|
|
|
/* void Mat3CpyMat4(float m1p[][3], float m2p[][4]); */
|
|
|
|
|
/* void Mat3CpyMat4(float *m1p, float *m2p); */
|
|
|
|
|
|
|
|
|
|
/* m1 to m2 */
|
|
|
|
|
/* void Mat3CpyMat3(float m1p[][3], float m2p[][3]); */
|
|
|
|
|
/* void Mat3CpyMat3(float *m1p, float *m2p); */
|
|
|
|
|
|
|
|
|
|
/* m2 to m1 */
|
|
|
|
|
/* void Mat4CpyMat3(float m1p[][4], float m2p[][3]); */
|
|
|
|
|
|
|
|
|
|
/* M1 = M3*M2 */
|
|
|
|
|
/* void Mat3MulMat3(float m1[][3], float m2[][3], float m3[][3]); */
|
|
|
|
|
/*void Mat3MulMat3(float *m1, float *m3, float *m2); */
|
|
|
|
|
|
|
|
|
|
/* m1 = m2 * m3, ignore the elements on the 4th row/column of m3 */
|
|
|
|
|
/*void Mat3IsMat3MulMat4(float m1[][3], float m2[][3], float m3[][4]); */
|
|
|
|
|
|
|
|
|
|
/* m1 to m2 */
|
|
|
|
|
/* void Mat4CpyMat4(float m1[][4], float m2[][4]); */
|
|
|
|
|
/* void Mat4CpyMat4(float *m1, float *m2); */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* void Mat4Ortho(float mat[][4]); */
|
|
|
|
|
/* void Mat4Mul3Vecfl(float mat[][4], float *vec); */
|
|
|
|
|
/* void Mat4MulVec4fl(float mat[][4], float *vec); */
|
|
|
|
|
/* void Mat4SwapMat4(float *m1, float *m2); */
|
|
|
|
|
|
|
|
|
|
/* void Mat3Inv(float m1[][3], float m2[][3]); */
|
|
|
|
|
/* void Mat4One(float m[][4]); */
|
|
|
|
|
/* void Mat3One(float m[][3]); */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CalcCent3f(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *cent, float *v1, float *v2, float *v3
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CalcCent4f(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *cent, float *v1,
|
|
|
|
|
float *v2, float *v3,
|
|
|
|
|
float *v4
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Crossf(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *c, float *a, float *b
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
|
2003-10-21 13:22:07 +00:00
|
|
|
void
|
|
|
|
|
Projf(
|
2003-12-24 11:44:57 +00:00
|
|
|
float *c, float *v1, float *v2
|
2003-10-21 13:22:07 +00:00
|
|
|
);
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
|
* Euler conversion routines
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
EulToMat3(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *eul,
|
2002-10-12 11:37:38 +00:00
|
|
|
float mat[][3]
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
EulToMat4(
|
2003-07-02 13:37:03 +00:00
|
|
|
float* eul,
|
2002-10-12 11:37:38 +00:00
|
|
|
float mat[][4]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mat3ToEul(
|
2003-07-02 13:37:03 +00:00
|
|
|
float tmat[][3],
|
2002-10-12 11:37:38 +00:00
|
|
|
float *eul
|
|
|
|
|
);
|
|
|
|
|
|
2006-06-03 17:21:45 +00:00
|
|
|
void compatible_eul(float *eul, float *oldrot);
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
|
* @section Quaternion arithmetic routines
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
QuatToEul(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *quat,
|
2002-10-12 11:37:38 +00:00
|
|
|
float *eul
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
QuatOne(
|
|
|
|
|
float *
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
QuatMul(
|
|
|
|
|
float *,
|
2003-07-02 13:37:03 +00:00
|
|
|
float *,
|
|
|
|
|
float *
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
2005-07-05 00:30:40 +00:00
|
|
|
QuatMulVecf(
|
|
|
|
|
float *q,
|
|
|
|
|
float *v
|
|
|
|
|
);
|
|
|
|
|
void
|
2002-10-12 11:37:38 +00:00
|
|
|
NormalQuat(
|
|
|
|
|
float *
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
VecRotToQuat(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *vec,
|
2002-10-12 11:37:38 +00:00
|
|
|
float phi,
|
|
|
|
|
float *quat
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
QuatSub(
|
|
|
|
|
float *q,
|
2003-07-02 13:37:03 +00:00
|
|
|
float *q1,
|
2002-10-12 11:37:38 +00:00
|
|
|
float *q2
|
|
|
|
|
);
|
2005-07-05 00:30:40 +00:00
|
|
|
void
|
|
|
|
|
QuatConj(
|
|
|
|
|
float *q
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
QuatInv(
|
|
|
|
|
float *q
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
QuatMulf(
|
|
|
|
|
float *q,
|
|
|
|
|
float f
|
|
|
|
|
);
|
|
|
|
|
float
|
|
|
|
|
QuatDot(
|
|
|
|
|
float *q1,
|
|
|
|
|
float *q2
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
printquat(
|
|
|
|
|
char *str,
|
|
|
|
|
float q[4]
|
|
|
|
|
);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-11-11 13:17:32 +00:00
|
|
|
|
|
|
|
|
void QuatInterpol(float *result, float *quat1, float *quat2, float t);
|
|
|
|
|
void QuatAdd(float *result, float *quat1, float *quat2, float t);
|
|
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
|
* @section matrix multiplication can copying routines
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mat3MulFloat(
|
|
|
|
|
float *m,
|
|
|
|
|
float f
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat4MulFloat(
|
|
|
|
|
float *m,
|
|
|
|
|
float f
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat4MulFloat3(
|
|
|
|
|
float *m,
|
|
|
|
|
float f
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat3Transp(
|
|
|
|
|
float mat[][3]
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat4Transp(
|
|
|
|
|
float mat[][4]
|
|
|
|
|
);
|
|
|
|
|
int
|
|
|
|
|
Mat4Invert(
|
|
|
|
|
float inverse[][4],
|
2003-07-02 13:37:03 +00:00
|
|
|
float mat[][4]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat4InvertSimp(
|
|
|
|
|
float inverse[][4],
|
2003-07-02 13:37:03 +00:00
|
|
|
float mat[][4]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat4Inv(
|
|
|
|
|
float *m1,
|
2003-07-02 13:37:03 +00:00
|
|
|
float *m2
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat4InvGG(
|
|
|
|
|
float out[][4],
|
2003-07-02 13:37:03 +00:00
|
|
|
float in[][4]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat3CpyMat4(
|
|
|
|
|
float m1[][3],
|
2003-07-02 13:37:03 +00:00
|
|
|
float m2[][4]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mat3Inv(
|
|
|
|
|
float m1[][3],
|
2003-07-02 13:37:03 +00:00
|
|
|
float m2[][3]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mat4CpyMat3(
|
|
|
|
|
float m1[][4],
|
2003-07-02 13:37:03 +00:00
|
|
|
float m2[][3]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
float
|
|
|
|
|
Det2x2(
|
|
|
|
|
float a,float b,float c,float d
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
float
|
|
|
|
|
Det3x3(
|
|
|
|
|
float a1, float a2, float a3,
|
|
|
|
|
float b1, float b2, float b3,
|
|
|
|
|
float c1, float c2, float c3
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
float
|
|
|
|
|
Det4x4(
|
2003-07-02 13:37:03 +00:00
|
|
|
float m[][4]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mat4Adj(
|
|
|
|
|
float out[][4],
|
2003-07-02 13:37:03 +00:00
|
|
|
float in[][4]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat3Adj(
|
|
|
|
|
float m1[][3],
|
2003-07-02 13:37:03 +00:00
|
|
|
float m[][3]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat4MulMat4(
|
|
|
|
|
float m1[][4],
|
2003-07-02 13:37:03 +00:00
|
|
|
float m2[][4],
|
|
|
|
|
float m3[][4]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
subMat4MulMat4(
|
|
|
|
|
float *m1,
|
2003-07-02 13:37:03 +00:00
|
|
|
float *m2,
|
|
|
|
|
float *m3
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
#ifndef TEST_ACTIVE
|
|
|
|
|
void
|
|
|
|
|
Mat3MulMat3(
|
|
|
|
|
float m1[][3],
|
2003-07-02 13:37:03 +00:00
|
|
|
float m3[][3],
|
|
|
|
|
float m2[][3]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
#else
|
|
|
|
|
void
|
|
|
|
|
Mat3MulMat3(
|
|
|
|
|
float *m1,
|
2003-07-02 13:37:03 +00:00
|
|
|
float *m3,
|
|
|
|
|
float *m2
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
#endif
|
|
|
|
|
void
|
|
|
|
|
Mat4MulMat34(
|
|
|
|
|
float (*m1)[4],
|
2003-07-02 13:37:03 +00:00
|
|
|
float (*m3)[3],
|
|
|
|
|
float (*m2)[4]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat4CpyMat4(
|
|
|
|
|
float m1[][4],
|
2003-07-02 13:37:03 +00:00
|
|
|
float m2[][4]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat4SwapMat4(
|
|
|
|
|
float *m1,
|
|
|
|
|
float *m2
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat3CpyMat3(
|
|
|
|
|
float m1[][3],
|
2003-07-02 13:37:03 +00:00
|
|
|
float m2[][3]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat3MulSerie(
|
|
|
|
|
float answ[][3],
|
2003-07-02 13:37:03 +00:00
|
|
|
float m1[][3], float m2[][3], float m3[][3],
|
|
|
|
|
float m4[][3], float m5[][3], float m6[][3],
|
|
|
|
|
float m7[][3], float m8[][3]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat4MulSerie(
|
|
|
|
|
float answ[][4],
|
2003-07-02 13:37:03 +00:00
|
|
|
float m1[][4],
|
|
|
|
|
float m2[][4], float m3[][4], float m4[][4],
|
|
|
|
|
float m5[][4], float m6[][4], float m7[][4],
|
|
|
|
|
float m8[][4]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat4Clr(
|
|
|
|
|
float *m
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat3Clr(
|
|
|
|
|
float *m
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat3One(
|
|
|
|
|
float m[][3]
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat4MulVec(
|
2003-07-02 13:37:03 +00:00
|
|
|
float mat[][4],
|
2002-10-12 11:37:38 +00:00
|
|
|
int *vec
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
VecMat4MulVecfl(
|
|
|
|
|
float *in,
|
2003-07-02 13:37:03 +00:00
|
|
|
float mat[][4],
|
|
|
|
|
float *vec
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat4MulMat43(
|
|
|
|
|
float (*m1)[4],
|
2003-07-02 13:37:03 +00:00
|
|
|
float (*m3)[4],
|
|
|
|
|
float (*m2)[3]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mat3IsMat3MulMat4(
|
|
|
|
|
float m1[][3],
|
2003-07-02 13:37:03 +00:00
|
|
|
float m2[][3],
|
|
|
|
|
float m3[][4]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat4One(
|
|
|
|
|
float m[][4]
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat4Mul3Vecfl(
|
2003-07-02 13:37:03 +00:00
|
|
|
float mat[][4],
|
2002-10-12 11:37:38 +00:00
|
|
|
float *vec
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat4MulVec4fl(
|
2003-07-02 13:37:03 +00:00
|
|
|
float mat[][4],
|
2002-10-12 11:37:38 +00:00
|
|
|
float *vec
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat3MulVec(
|
2003-07-02 13:37:03 +00:00
|
|
|
float mat[][3],
|
2002-10-12 11:37:38 +00:00
|
|
|
int *vec
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat4MulVecfl(
|
2003-07-02 13:37:03 +00:00
|
|
|
float mat[][4],
|
2002-10-12 11:37:38 +00:00
|
|
|
float *vec
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat4ToQuat(
|
2003-07-02 13:37:03 +00:00
|
|
|
float m[][4],
|
2002-10-12 11:37:38 +00:00
|
|
|
float *q
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
VecUpMat3old(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *vec,
|
2002-10-12 11:37:38 +00:00
|
|
|
float mat[][3],
|
|
|
|
|
short axis
|
|
|
|
|
);
|
|
|
|
|
int
|
|
|
|
|
FloatCompare(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *v1,
|
|
|
|
|
float *v2,
|
2002-10-12 11:37:38 +00:00
|
|
|
float limit
|
|
|
|
|
);
|
|
|
|
|
float
|
|
|
|
|
Normalise(
|
|
|
|
|
float *n
|
|
|
|
|
);
|
|
|
|
|
float
|
|
|
|
|
CalcNormFloat(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *v1,
|
|
|
|
|
float *v2,
|
|
|
|
|
float *v3,
|
2002-10-12 11:37:38 +00:00
|
|
|
float *n
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
float
|
|
|
|
|
CalcNormFloat4(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *v1,
|
|
|
|
|
float *v2,
|
|
|
|
|
float *v3,
|
|
|
|
|
float *v4,
|
2002-10-12 11:37:38 +00:00
|
|
|
float *n
|
|
|
|
|
);
|
|
|
|
|
float
|
|
|
|
|
VecLenf(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *v1,
|
|
|
|
|
float *v2
|
2005-03-31 13:44:23 +00:00
|
|
|
);
|
|
|
|
|
float
|
|
|
|
|
VecLength(
|
|
|
|
|
float *v
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
VecMulf(
|
|
|
|
|
float *v1,
|
|
|
|
|
float f
|
2006-03-01 15:30:10 +00:00
|
|
|
);
|
|
|
|
|
int
|
|
|
|
|
VecLenCompare(
|
|
|
|
|
float *v1,
|
|
|
|
|
float *v2,
|
|
|
|
|
float limit
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
int
|
|
|
|
|
VecCompare(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *v1,
|
|
|
|
|
float *v2,
|
2002-10-12 11:37:38 +00:00
|
|
|
float limit
|
|
|
|
|
);
|
|
|
|
|
float
|
|
|
|
|
Sqrt3f(
|
|
|
|
|
float f
|
|
|
|
|
);
|
|
|
|
|
double
|
|
|
|
|
Sqrt3d(
|
|
|
|
|
double d
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
euler_rot(
|
|
|
|
|
float *beul,
|
|
|
|
|
float ang,
|
|
|
|
|
char axis
|
|
|
|
|
);
|
|
|
|
|
float
|
|
|
|
|
saacos(
|
|
|
|
|
float fac
|
|
|
|
|
);
|
|
|
|
|
float
|
|
|
|
|
sasqrt(
|
|
|
|
|
float fac
|
2004-04-24 21:09:06 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
printvecf(
|
|
|
|
|
char *str,
|
|
|
|
|
float v[3]
|
2005-02-27 19:14:21 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
printvec4f(
|
|
|
|
|
char *str,
|
|
|
|
|
float v[4]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
float
|
|
|
|
|
Inpf(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *v1,
|
|
|
|
|
float *v2
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
VecSubf(
|
|
|
|
|
float *v,
|
2003-07-02 13:37:03 +00:00
|
|
|
float *v1,
|
|
|
|
|
float *v2
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
VecAddf(
|
|
|
|
|
float *v,
|
2003-07-02 13:37:03 +00:00
|
|
|
float *v1,
|
|
|
|
|
float *v2
|
2005-08-08 18:50:47 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
VecLerpf(
|
|
|
|
|
float *target,
|
|
|
|
|
float *a,
|
|
|
|
|
float *b,
|
|
|
|
|
float t
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
VecUpMat3(
|
|
|
|
|
float *vec,
|
|
|
|
|
float mat[][3],
|
|
|
|
|
short axis
|
|
|
|
|
);
|
|
|
|
|
float
|
|
|
|
|
DistVL2Dfl(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *v1,
|
|
|
|
|
float *v2,
|
|
|
|
|
float *v3
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
float
|
|
|
|
|
PdistVL2Dfl(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *v1,
|
|
|
|
|
float *v2,
|
|
|
|
|
float *v3
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
float
|
|
|
|
|
AreaF2Dfl(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *v1,
|
|
|
|
|
float *v2,
|
|
|
|
|
float *v3
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
float
|
|
|
|
|
AreaQ3Dfl(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *v1,
|
|
|
|
|
float *v2,
|
|
|
|
|
float *v3,
|
|
|
|
|
float *v4
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
float
|
|
|
|
|
AreaT3Dfl(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *v1,
|
|
|
|
|
float *v2,
|
|
|
|
|
float *v3
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
float
|
|
|
|
|
AreaPoly3Dfl(
|
|
|
|
|
int nr,
|
2003-07-02 13:37:03 +00:00
|
|
|
float *verts,
|
|
|
|
|
float *normal
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
VecRotToMat3(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *vec,
|
2002-10-12 11:37:38 +00:00
|
|
|
float phi,
|
|
|
|
|
float mat[][3]
|
|
|
|
|
);
|
2004-11-03 11:25:27 +00:00
|
|
|
|
|
|
|
|
/* intersect Line-Line
|
|
|
|
|
return:
|
|
|
|
|
-1: colliniar
|
|
|
|
|
0: no intersection of segments
|
|
|
|
|
1: exact intersection of segments
|
|
|
|
|
2: cross-intersection of segments
|
|
|
|
|
*/
|
|
|
|
|
extern short IsectLL2Df(float *v1, float *v2, float *v3, float *v4);
|
|
|
|
|
extern short IsectLL2Ds(short *v1, short *v2, short *v3, short *v4);
|
|
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
float *
|
|
|
|
|
vectoquat(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *vec,
|
2002-10-12 11:37:38 +00:00
|
|
|
short axis,
|
|
|
|
|
short upflag
|
|
|
|
|
);
|
|
|
|
|
|
2005-01-08 21:16:24 +00:00
|
|
|
float
|
|
|
|
|
VecAngle3(
|
|
|
|
|
float *v1,
|
|
|
|
|
float *v2,
|
|
|
|
|
float *v3
|
|
|
|
|
);
|
|
|
|
|
|
2006-03-25 06:32:39 +00:00
|
|
|
float
|
|
|
|
|
VecAngle2(
|
|
|
|
|
float *v1,
|
|
|
|
|
float *v2
|
|
|
|
|
);
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
void
|
|
|
|
|
i_lookat(
|
|
|
|
|
float vx, float vy,
|
|
|
|
|
float vz, float px,
|
|
|
|
|
float py, float pz,
|
|
|
|
|
float twist, float mat[][4]
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
i_window(
|
|
|
|
|
float left, float right,
|
|
|
|
|
float bottom, float top,
|
|
|
|
|
float nearClip, float farClip,
|
|
|
|
|
float mat[][4]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
hsv_to_rgb(
|
|
|
|
|
float h, float s,
|
|
|
|
|
float v, float *r,
|
|
|
|
|
float *g, float *b
|
|
|
|
|
);
|
|
|
|
|
|
2005-10-04 21:23:19 +00:00
|
|
|
void hex_to_rgb(char *hexcol, float *r, float *g, float *b);
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
void
|
|
|
|
|
rgb_to_hsv(
|
|
|
|
|
float r, float g, float b,
|
|
|
|
|
float *lh, float *ls, float *lv
|
|
|
|
|
);
|
|
|
|
|
unsigned int
|
|
|
|
|
hsv_to_cpack(
|
|
|
|
|
float h, float s, float v
|
|
|
|
|
);
|
|
|
|
|
unsigned int
|
|
|
|
|
rgb_to_cpack(
|
|
|
|
|
float r, float g, float b
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
cpack_to_rgb(
|
|
|
|
|
unsigned int col,
|
|
|
|
|
float *r, float *g, float *b
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
EulToQuat(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *eul,
|
2002-10-12 11:37:38 +00:00
|
|
|
float *quat
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Mat3MulVecfl(
|
2003-07-02 13:37:03 +00:00
|
|
|
float mat[][3],
|
2002-10-12 11:37:38 +00:00
|
|
|
float *vec
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat3MulVecd(
|
2003-07-02 13:37:03 +00:00
|
|
|
float mat[][3],
|
2002-10-12 11:37:38 +00:00
|
|
|
double *vec
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat3TransMulVecfl(
|
2003-07-02 13:37:03 +00:00
|
|
|
float mat[][3],
|
2002-10-12 11:37:38 +00:00
|
|
|
float *vec
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
VecStar(
|
|
|
|
|
float mat[][3],
|
2003-07-02 13:37:03 +00:00
|
|
|
float *vec
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
short
|
|
|
|
|
EenheidsMat(
|
|
|
|
|
float mat[][3]
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
printmatrix3(
|
2003-07-02 13:37:03 +00:00
|
|
|
char *str, float m[][3]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
QuatToMat3(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *q,
|
2002-10-12 11:37:38 +00:00
|
|
|
float m[][3]
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
QuatToMat4(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *q,
|
2002-10-12 11:37:38 +00:00
|
|
|
float m[][4]
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat3ToQuat_is_ok(
|
2003-07-02 13:37:03 +00:00
|
|
|
float wmat[][3],
|
2002-10-12 11:37:38 +00:00
|
|
|
float *q
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
i_ortho(
|
|
|
|
|
float left, float right,
|
|
|
|
|
float bottom, float top,
|
|
|
|
|
float nearClip, float farClip,
|
|
|
|
|
float matrix[][4]
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
i_polarview(
|
|
|
|
|
float dist, float azimuth, float incidence, float twist,
|
|
|
|
|
float Vm[][4]
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat3Ortho(
|
|
|
|
|
float mat[][3]
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat4Ortho(
|
|
|
|
|
float mat[][4]
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
VecCopyf(
|
|
|
|
|
float *v1,
|
2003-07-02 13:37:03 +00:00
|
|
|
float *v2
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
int
|
|
|
|
|
VecLen(
|
2003-07-02 13:37:03 +00:00
|
|
|
int *v1,
|
|
|
|
|
int *v2
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
CalcNormShort(
|
2003-07-02 13:37:03 +00:00
|
|
|
short *v1,
|
|
|
|
|
short *v2,
|
|
|
|
|
short *v3,
|
2002-10-12 11:37:38 +00:00
|
|
|
float *n
|
|
|
|
|
) /* is ook uitprodukt */;
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CalcNormLong(
|
2003-07-02 13:37:03 +00:00
|
|
|
int* v1,
|
|
|
|
|
int*v2,
|
|
|
|
|
int*v3,
|
2002-10-12 11:37:38 +00:00
|
|
|
float *n
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
MinMax3(
|
|
|
|
|
float *min,
|
|
|
|
|
float *max,
|
2003-07-02 13:37:03 +00:00
|
|
|
float *vec
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat3ToEuln(
|
2003-07-02 13:37:03 +00:00
|
|
|
float tmat[][3],
|
2002-10-12 11:37:38 +00:00
|
|
|
float *eul
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
SizeToMat3(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *size,
|
2002-10-12 11:37:38 +00:00
|
|
|
float mat[][3]
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
printmatrix4(
|
2003-07-02 13:37:03 +00:00
|
|
|
char *str,
|
|
|
|
|
float m[][4]
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
/* uit Sig.Proc.85 pag 253 */
|
|
|
|
|
void
|
|
|
|
|
Mat3ToQuat(
|
2003-07-02 13:37:03 +00:00
|
|
|
float wmat[][3],
|
2002-10-12 11:37:38 +00:00
|
|
|
float *q
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
i_translate(
|
|
|
|
|
float Tx,
|
|
|
|
|
float Ty,
|
|
|
|
|
float Tz,
|
|
|
|
|
float mat[][4]
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
i_multmatrix(
|
2003-07-02 13:37:03 +00:00
|
|
|
float icand[][4],
|
2002-10-12 11:37:38 +00:00
|
|
|
float Vm[][4]
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
i_rotate(
|
|
|
|
|
float angle,
|
|
|
|
|
char axis,
|
|
|
|
|
float mat[][4]
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
VecMidf(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *v, float *v1, float *v2
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat3ToSize(
|
2003-07-02 13:37:03 +00:00
|
|
|
float mat[][3], float *size
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Mat4ToSize(
|
2003-07-02 13:37:03 +00:00
|
|
|
float mat[][4], float *size
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
triatoquat(
|
2003-07-02 13:37:03 +00:00
|
|
|
float *v1,
|
|
|
|
|
float *v2,
|
|
|
|
|
float *v3, float *quat
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
MinMaxRGB(
|
|
|
|
|
short c[]
|
|
|
|
|
);
|
Added LSCM UV Unwrapping:
http://www.loria.fr/~levy/Galleries/LSCM/index.html
http://www.loria.fr/~levy/Papers/2002/s2002_lscm.pdf
Implementation Least Squares Conformal Maps parameterization, based on
chapter 2 of:
Bruno Levy, Sylvain Petitjean, Nicolas Ray, Jerome Maillot. Least Squares
Conformal Maps for Automatic Texture Atlas Generation. In Siggraph 2002,
July 2002.
Seams: Stored as a flag (ME_SEAM) in the new MEdge struct, these seams define
where a mesh will be cut when executing LSCM unwrapping. Seams can be marked
and cleared in Edit Mode. Ctrl+EKEY will pop up a menu allowing to Clear or Mark
the selected edges as seams.
Select Linked in Face Select Mode now only selects linked faces if no seams
separate them. So if seams are defined, this will now select the 'face group'
defined by the seams. Hotkey is still LKEY.
LSCM Unwrap: unwrap UV's by calculating a conformal mapping (preserving local
angles). Based on seams, the selected faces will be 'cut'. If multiple
'face groups' are selected, they will be unwrapped separately and packed in
the image rectangle in the UV Editor. Packing uses a simple and fast
algorithm, only designed to avoid having overlapping faces.
LSCM can be found in the Unwrap menu (UKEY), and the UV Calculation panel.
Pinning: UV's can be pinned in the UV Editor. When LSCM Unwrap is then
executed, these UV's will stay in place, allowing to tweak the solution.
PKEY and ALT+PKEY will respectively pin and unpin selected UV's.
Face Select Mode Drawing Changes:
- Draw Seams option to enable disable drawing of seams
- Draw Faces option to enable drawing of selected faces in transparent purple
- Draw Hidden Edges option to enable drawing of edges of hidden faces
- Draw Edges option to enable drawing of edges of visible faces
The colors for these seams, faces and edges are themeable.
2004-07-13 11:48:52 +00:00
|
|
|
float
|
|
|
|
|
Vec2Lenf(
|
|
|
|
|
float *v1,
|
|
|
|
|
float *v2
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Vec2Mulf(
|
|
|
|
|
float *v1,
|
|
|
|
|
float f
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Vec2Addf(
|
|
|
|
|
float *v,
|
|
|
|
|
float *v1,
|
|
|
|
|
float *v2
|
|
|
|
|
);
|
2005-04-22 20:16:02 +00:00
|
|
|
void
|
|
|
|
|
Vec2Subf(
|
|
|
|
|
float *v,
|
|
|
|
|
float *v1,
|
|
|
|
|
float *v2
|
|
|
|
|
);
|
|
|
|
|
void
|
|
|
|
|
Vec2Copyf(
|
|
|
|
|
float *v1,
|
|
|
|
|
float *v2
|
|
|
|
|
);
|
|
|
|
|
float
|
|
|
|
|
Inp2f(
|
|
|
|
|
float *v1,
|
|
|
|
|
float *v2
|
|
|
|
|
);
|
|
|
|
|
float
|
|
|
|
|
Normalise2(
|
|
|
|
|
float *n
|
|
|
|
|
);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
Biiig commit! Thanks to 2-3 weeks of cvs freeze...
Render:
- New; support for dual CPU render (SDL thread)
Currently only works with alternating scanlines, but gives excellent
performance. For both normal render as unified implemented.
Note the "mutex" locks on z-transp buffer render and imbuf loads.
- This has been made possible by major cleanups in render code, especially
getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct
OSA or using Materials or Texture data to write to.
- Made normal render fully 4x32 floats too, and removed all old optimizes
with chars or shorts.
- Made normal render and unified render use same code for sky and halo
render, giving equal (and better) results for halo render. Old render
now also uses PostProcess options (brightness, mul, gamma)
- Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer
after render. Using PostProcess menu you will note an immediate re-
display of image too (32 bits RGBA)
- Added "Hue" and "Saturation" sliders to PostProcess options
- Render module is still not having a "nice" API, but amount of dependencies
went down a lot. Next todo: remove abusive "previewrender" code.
The last main global in Render (struct Render) now can be re-used for fully
controlling a render, to allow multiple "instances" of render to open.
- Renderwindow now displays a smal bar on top with the stats, and keeps the
stats after render too. Including "spare" page support.
Not only easier visible that way, but also to remove the awkward code that
was drawing stats in the Info header (extreme slow on some ATIs too)
- Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping
defines.
- I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
|
|
|
void tubemap(float x, float y, float z, float *u, float *v);
|
|
|
|
|
void spheremap(float x, float y, float z, float *u, float *v);
|
|
|
|
|
|
2005-08-19 22:55:05 +00:00
|
|
|
int LineIntersectsTriangle(float p1[3], float p2[3], float v0[3], float v1[3], float v2[3], float *lambda);
|
Biiig commit! Thanks to 2-3 weeks of cvs freeze...
Render:
- New; support for dual CPU render (SDL thread)
Currently only works with alternating scanlines, but gives excellent
performance. For both normal render as unified implemented.
Note the "mutex" locks on z-transp buffer render and imbuf loads.
- This has been made possible by major cleanups in render code, especially
getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct
OSA or using Materials or Texture data to write to.
- Made normal render fully 4x32 floats too, and removed all old optimizes
with chars or shorts.
- Made normal render and unified render use same code for sky and halo
render, giving equal (and better) results for halo render. Old render
now also uses PostProcess options (brightness, mul, gamma)
- Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer
after render. Using PostProcess menu you will note an immediate re-
display of image too (32 bits RGBA)
- Added "Hue" and "Saturation" sliders to PostProcess options
- Render module is still not having a "nice" API, but amount of dependencies
went down a lot. Next todo: remove abusive "previewrender" code.
The last main global in Render (struct Render) now can be re-used for fully
controlling a render, to allow multiple "instances" of render to open.
- Renderwindow now displays a smal bar on top with the stats, and keeps the
stats after render too. Including "spare" page support.
Not only easier visible that way, but also to remove the awkward code that
was drawing stats in the Info header (extreme slow on some ATIs too)
- Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping
defines.
- I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|
2002-10-30 02:07:20 +00:00
|
|
|
|