You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(46) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(185) |
Feb
(242) |
Mar
(237) |
Apr
(180) |
May
(102) |
Jun
(278) |
Jul
(114) |
Aug
(92) |
Sep
(246) |
Oct
(212) |
Nov
(279) |
Dec
(99) |
| 2007 |
Jan
(130) |
Feb
(194) |
Mar
(22) |
Apr
(72) |
May
(40) |
Jun
(111) |
Jul
(114) |
Aug
(154) |
Sep
(114) |
Oct
(2) |
Nov
(1) |
Dec
(5) |
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(6) |
Oct
(51) |
Nov
(34) |
Dec
(130) |
| 2009 |
Jan
(22) |
Feb
(20) |
Mar
(41) |
Apr
(45) |
May
(82) |
Jun
(96) |
Jul
(48) |
Aug
(90) |
Sep
(13) |
Oct
(49) |
Nov
(31) |
Dec
(21) |
| 2010 |
Jan
(25) |
Feb
(9) |
Mar
(7) |
Apr
(28) |
May
(27) |
Jun
(7) |
Jul
(1) |
Aug
|
Sep
(1) |
Oct
(1) |
Nov
(13) |
Dec
(2) |
| 2013 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <axl...@us...> - 2010-05-03 02:12:00
|
Revision: 718
http://hgengine.svn.sourceforge.net/hgengine/?rev=718&view=rev
Author: axlecrusher
Date: 2010-05-03 02:11:54 +0000 (Mon, 03 May 2010)
Log Message:
-----------
Take advantage of the source and destination matrices being able to be the same address.
Modified Paths:
--------------
Mercury2/src/MercuryMatrix.cpp
Modified: Mercury2/src/MercuryMatrix.cpp
===================================================================
--- Mercury2/src/MercuryMatrix.cpp 2010-05-03 02:07:24 UTC (rev 717)
+++ Mercury2/src/MercuryMatrix.cpp 2010-05-03 02:11:54 UTC (rev 718)
@@ -209,7 +209,7 @@
{
MercuryMatrix m;
q.toMatrix4( m );
- *this *= m;
+ MatrixMultiply4f( m_matrix, m.m_matrix, m_matrix );
}
void MercuryMatrix::Transotale( float tX, float tY, float tZ, float rX, float rY, float rZ, float sX, float sY, float sZ )
@@ -261,20 +261,19 @@
m[1][1] = y;
m[2][2] = z;
- *this *= m;
+ MatrixMultiply4f ( m_matrix, m.m_matrix, m_matrix);
}
MercuryMatrix MercuryMatrix::operator*(const MercuryMatrix& m) const
{
- MercuryMatrix r(*this);
+ MercuryMatrix r;
MatrixMultiply4f ( m_matrix, m.m_matrix, r.m_matrix);
return r;
}
MercuryMatrix& MercuryMatrix::operator*=(const MercuryMatrix& m)
{
- MercuryMatrix r(*this);
- MatrixMultiply4f ( r.m_matrix, m.m_matrix, m_matrix);
+ MatrixMultiply4f ( m_matrix, m.m_matrix, m_matrix);
return *this;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-03 02:07:30
|
Revision: 717
http://hgengine.svn.sourceforge.net/hgengine/?rev=717&view=rev
Author: axlecrusher
Date: 2010-05-03 02:07:24 +0000 (Mon, 03 May 2010)
Log Message:
-----------
Don't write results directly to output reference. Use local variables and copy the results then the calculations are finished. This allows the input and output to be the same address.
Modified Paths:
--------------
Mercury2/src/MercuryMath.cpp
Modified: Mercury2/src/MercuryMath.cpp
===================================================================
--- Mercury2/src/MercuryMath.cpp 2010-05-02 14:32:43 UTC (rev 716)
+++ Mercury2/src/MercuryMath.cpp 2010-05-03 02:07:24 UTC (rev 717)
@@ -41,26 +41,34 @@
void Mul4f(const FloatRow& first, const FloatRow& second, FloatRow& out)
{
+ FloatRow r;
for (uint8_t i = 0; i < 4; ++i)
- out[i] = first[i] * second[i];
+ r[i] = first[i] * second[i];
+ Copy4f(out,r);
}
void Div4f(const FloatRow& first, const FloatRow& second, FloatRow& out)
{
+ FloatRow r;
for (uint8_t i = 0; i < 4; ++i)
out[i] = first[i] / second[i];
+ Copy4f(out,r);
}
void Add4f(const FloatRow& first, const FloatRow& second, FloatRow& out)
{
+ FloatRow r;
for (uint8_t i = 0; i < 4; ++i)
out[i] = first[i] + second[i];
+ Copy4f(out,r);
}
void Sub4f(const FloatRow& first, const FloatRow& second, FloatRow& out)
{
+ FloatRow r;
for (uint8_t i = 0; i < 4; ++i)
out[i] = first[i] - second[i];
+ Copy4f(out,r);
}
void Copy4f( void * dest, const void * source )
@@ -82,56 +90,61 @@
{
const float *in1 = *in1a;
const float *in2 = *in2a;
- float *out = *outa;
+ FloatRow r[4];
- out[0] = in1[0] * in2[0] + in1[1] * in2[4] +
+ (*r)[0] = in1[0] * in2[0] + in1[1] * in2[4] +
in1[2] * in2[8] + in1[3] * in2[12];
- out[1] = in1[0] * in2[1] + in1[1] * in2[5] +
+ (*r)[1] = in1[0] * in2[1] + in1[1] * in2[5] +
in1[2] * in2[9] + in1[3] * in2[13];
- out[2] = in1[0] * in2[2] + in1[1] * in2[6] +
+ (*r)[2] = in1[0] * in2[2] + in1[1] * in2[6] +
in1[2] * in2[10] + in1[3] * in2[14];
- out[3] = in1[0] * in2[3] + in1[1] * in2[7] +
+ (*r)[3] = in1[0] * in2[3] + in1[1] * in2[7] +
in1[2] * in2[11] + in1[3] * in2[15];
- out[4] = in1[4] * in2[0] + in1[5] * in2[4] +
+ (*r)[4] = in1[4] * in2[0] + in1[5] * in2[4] +
in1[6] * in2[8] + in1[7] * in2[12];
- out[5] = in1[4] * in2[1] + in1[5] * in2[5] +
+ (*r)[5] = in1[4] * in2[1] + in1[5] * in2[5] +
in1[6] * in2[9] + in1[7] * in2[13];
- out[6] = in1[4] * in2[2] + in1[5] * in2[6] +
+ (*r)[6] = in1[4] * in2[2] + in1[5] * in2[6] +
in1[6] * in2[10] + in1[7] * in2[14];
- out[7] = in1[4] * in2[3] + in1[5] * in2[7] +
+ (*r)[7] = in1[4] * in2[3] + in1[5] * in2[7] +
in1[6] * in2[11] + in1[7] * in2[15];
- out[8] = in1[8] * in2[0] + in1[9] * in2[4] +
+ (*r)[8] = in1[8] * in2[0] + in1[9] * in2[4] +
in1[10] * in2[8] + in1[11] * in2[12];
- out[9] = in1[8] * in2[1] + in1[9] * in2[5] +
+ (*r)[9] = in1[8] * in2[1] + in1[9] * in2[5] +
in1[10] * in2[9] + in1[11] * in2[13];
- out[10] = in1[8] * in2[2] + in1[9] * in2[6] +
+ (*r)[10] = in1[8] * in2[2] + in1[9] * in2[6] +
in1[10] * in2[10] + in1[11] * in2[14];
- out[11] = in1[8] * in2[3] + in1[9] * in2[7] +
+ (*r)[11] = in1[8] * in2[3] + in1[9] * in2[7] +
in1[10] * in2[11] + in1[11] * in2[15];
- out[12] = in1[12] * in2[0] + in1[13] * in2[4] +
+ (*r)[12] = in1[12] * in2[0] + in1[13] * in2[4] +
in1[14] * in2[8] + in1[15] * in2[12];
- out[13] = in1[12] * in2[1] + in1[13] * in2[5] +
+ (*r)[13] = in1[12] * in2[1] + in1[13] * in2[5] +
in1[14] * in2[9] + in1[15] * in2[13];
- out[14] = in1[12] * in2[2] + in1[13] * in2[6] +
+ (*r)[14] = in1[12] * in2[2] + in1[13] * in2[6] +
in1[14] * in2[10] + in1[15] * in2[14];
- out[15] = in1[12] * in2[3] + in1[13] * in2[7] +
+ (*r)[15] = in1[12] * in2[3] + in1[13] * in2[7] +
in1[14] * in2[11] + in1[15] * in2[15];
+
+ Copy16f(outa,r);
}
void VectorMultiply4f( const FloatRow* matrix, const FloatRow& pa, FloatRow& outa )
{
+ FloatRow r;
const float *m = *matrix;
const float *p = pa;
- float *out = outa;
- out[0] = p[0] * m[0] + p[1] * m[1] + p[2] * m[2] + p[3] * m[3];
- out[1] = p[0] * m[4] + p[1] * m[5] + p[2] * m[6] + p[3] * m[7];
- out[2] = p[0] * m[8] + p[1] * m[9] + p[2] * m[10] + p[3] * m[11];
- out[3] = p[0] * m[12] + p[1] * m[13] + p[2] * m[14] + p[3] * m[15];
+
+ r[0] = p[0] * m[0] + p[1] * m[1] + p[2] * m[2] + p[3] * m[3];
+ r[1] = p[0] * m[4] + p[1] * m[5] + p[2] * m[6] + p[3] * m[7];
+ r[2] = p[0] * m[8] + p[1] * m[9] + p[2] * m[10] + p[3] * m[11];
+ r[3] = p[0] * m[12] + p[1] * m[13] + p[2] * m[14] + p[3] * m[15];
+
+ Copy4f(outa,r);
}
-
+/*
void Float2FloatRow(const float* f, FloatRow& r)
{
for (uint8_t i = 0; i < 4; ++i)
@@ -143,12 +156,16 @@
for (uint8_t i = 0; i < 4; ++i)
f[i] = r[i];
}
-
+*/
void MMCrossProduct( const FloatRow& r1, const FloatRow& r2, FloatRow& result)
{
- result[0] = r1[1]*r2[2] - r1[2]*r2[1];
- result[1] = r1[2]*r2[0] - r1[0]*r2[2];
- result[2] = r1[0]*r2[1] - r1[1]*r2[0];
+ FloatRow r;
+
+ r[0] = r1[1]*r2[2] - r1[2]*r2[1];
+ r[1] = r1[2]*r2[0] - r1[0]*r2[2];
+ r[2] = r1[0]*r2[1] - r1[1]*r2[0];
+
+ Copy4f(result,r);
}
#else
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-02 14:32:49
|
Revision: 716
http://hgengine.svn.sourceforge.net/hgengine/?rev=716&view=rev
Author: axlecrusher
Date: 2010-05-02 14:32:43 +0000 (Sun, 02 May 2010)
Log Message:
-----------
fixe SSE since FloatRow is no longer __m128
Modified Paths:
--------------
Mercury2/src/MercuryMath.cpp
Modified: Mercury2/src/MercuryMath.cpp
===================================================================
--- Mercury2/src/MercuryMath.cpp 2010-04-29 23:53:04 UTC (rev 715)
+++ Mercury2/src/MercuryMath.cpp 2010-05-02 14:32:43 UTC (rev 716)
@@ -164,22 +164,38 @@
void Mul4f(const FloatRow& first, const FloatRow& second, FloatRow& out)
{
- out = _mm_mul_ps( first, second );
+ __m128 a,b,o;
+ a = _mm_load_ps(first);
+ b = _mm_load_ps(second);
+ o = _mm_mul_ps( a, b );
+ _mm_store_ps(out,o);
}
void Div4f(const FloatRow& first, const FloatRow& second, FloatRow& out)
{
- out = _mm_div_ps( first, second );
+ __m128 a,b,o;
+ a = _mm_load_ps(first);
+ b = _mm_load_ps(second);
+ o = _mm_div_ps( a, b );
+ _mm_store_ps(out,o);
}
void Add4f(const FloatRow& first, const FloatRow& second, FloatRow& out)
{
- out = _mm_add_ps( first, second );
+ __m128 a,b,o;
+ a = _mm_load_ps(first);
+ b = _mm_load_ps(second);
+ o = _mm_add_ps( a, b );
+ _mm_store_ps(out,o);
}
void Sub4f(const FloatRow& first, const FloatRow& second, FloatRow& out)
{
- out = _mm_sub_ps( first, second );
+ __m128 a,b,o;
+ a = _mm_load_ps(first);
+ b = _mm_load_ps(second);
+ o = _mm_sub_ps( a, b );
+ _mm_store_ps(out,o);
}
void Copy4f( void * dest, const void * source )
@@ -195,6 +211,11 @@
void Copy16f( void * dest, const void * source )
{
+/* _mm_stream_si128((__m128i*)dest,((__m128i*)source)[0]);
+ _mm_stream_si128(&((__m128i*)dest)[1],((__m128i*)source)[1]);
+ _mm_stream_si128(&((__m128i*)dest)[2],((__m128i*)source)[2]);
+ _mm_stream_si128(&((__m128i*)dest)[3],((__m128i*)source)[3]);
+*/
_mm_stream_ps(((float*)dest),((__m128*)source)[0]);
_mm_stream_ps(((float*)dest)+4,((__m128*)source)[1]);
_mm_stream_ps(((float*)dest)+8,((__m128*)source)[2]);
@@ -204,52 +225,68 @@
void MatrixMultiply4f( const FloatRow* in1, const FloatRow* in2, FloatRow* out)
{
unsigned int y;
- __m128 xmm[4];
+ __m128 xmm[4], a[4], b[4];
// PREFETCH(in1, _MM_HINT_T0);
// PREFETCH(in2, _MM_HINT_T1);
// PREFETCH(out, _MM_HINT_T1);
+ b[0] = _mm_load_ps(in2[0]);
+ b[1] = _mm_load_ps(in2[1]);
+ b[2] = _mm_load_ps(in2[2]);
+ b[3] = _mm_load_ps(in2[3]);
for (y = 0; y < 4; ++y)
{
+ a[y] = _mm_load_ps(in1[y]);
+
//load rows as columns
- xmm[3] = _mm_shuffle_ps (in1[y], in1[y], 0xff);
- xmm[2] = _mm_shuffle_ps (in1[y], in1[y], 0xaa);
- xmm[1] = _mm_shuffle_ps (in1[y], in1[y], 0x55);
- xmm[0] = _mm_shuffle_ps (in1[y], in1[y], 0x00);
+ xmm[3] = _mm_shuffle_ps (a[y], a[y], 0xff);
+ xmm[2] = _mm_shuffle_ps (a[y], a[y], 0xaa);
+ xmm[1] = _mm_shuffle_ps (a[y], a[y], 0x55);
+ xmm[0] = _mm_shuffle_ps (a[y], a[y], 0x00);
- xmm[0] = _mm_mul_ps( xmm[0], in2[0] );
- xmm[1] = _mm_mul_ps( xmm[1], in2[1] );
- xmm[2] = _mm_mul_ps( xmm[2], in2[2] );
- xmm[3] = _mm_mul_ps( xmm[3], in2[3] );
+ xmm[0] = _mm_mul_ps( xmm[0], b[0] );
+ xmm[1] = _mm_mul_ps( xmm[1], b[1] );
+ xmm[2] = _mm_mul_ps( xmm[2], b[2] );
+ xmm[3] = _mm_mul_ps( xmm[3], b[3] );
xmm[0] = _mm_add_ps( xmm[0], xmm[1] );
xmm[2] = _mm_add_ps( xmm[2], xmm[3] );
- out[y] = _mm_add_ps( xmm[0], xmm[2] );
+ a[y] = _mm_add_ps( xmm[0], xmm[2] );
}
+
+ //try to use the CPU's write-combining
+ _mm_store_ps(out[0], a[0]);
+ _mm_store_ps(out[1], a[1]);
+ _mm_store_ps(out[2], a[2]);
+ _mm_store_ps(out[3], a[3]);
}
//This is an SSE matrix vector multiply, see the standard C++ code
//for a clear algorithim. This seems like it works.
void VectorMultiply4f( const FloatRow* matrix, const FloatRow& p, FloatRow& out )
{
- __m128 tmp, XY;
+ __m128 tmp,tmp2, XY, pp;
+ pp=_mm_load_ps(p);
+
//compute term X and term Y and store them in the low order of XY
- XY = Hadd4( _mm_mul_ps( matrix[0], p ) ); //compute X
- tmp = Hadd4( _mm_mul_ps( matrix[1], p ) ); //compute Y
+ XY = Hadd4( _mm_mul_ps( _mm_load_ps(matrix[0]), pp ) ); //compute X
+ tmp = Hadd4( _mm_mul_ps( _mm_load_ps(matrix[1]), pp ) ); //compute Y
XY = _mm_unpacklo_ps(XY, tmp);
//compute term Z and term W and store them in the low order of out
- out = Hadd4( _mm_mul_ps( matrix[2], p ) ); //compute Z
- tmp = Hadd4( _mm_mul_ps( matrix[3], p ) ); //compute W
- out = _mm_unpacklo_ps(out, tmp);
+ tmp2 = Hadd4( _mm_mul_ps( _mm_load_ps(matrix[2]), pp ) ); //compute Z
+ tmp = Hadd4( _mm_mul_ps( _mm_load_ps(matrix[3]), pp ) ); //compute W
+ pp = _mm_unpacklo_ps(tmp2, tmp);
//shuffle the low order of XY into the loworder of out
//and shuffle the low order of out into the high order of out
- out = _mm_movelh_ps(XY, out);
+ tmp = _mm_movelh_ps(XY, pp);
+
+ _mm_store_ps(out, tmp);
}
-
+/*
void ZeroFloatRow(FloatRow& r)
{
r = _mm_setzero_ps();
@@ -264,20 +301,25 @@
{
_mm_store_ps( f, r );
}
-
+*/
void MMCrossProduct( const FloatRow& r1, const FloatRow& r2, FloatRow& result)
{
__m128 a,b,c,d,r;//using more registers is faster
+ __m128 t1,t2;
+
+ t1 = _mm_load_ps(r1);
+ t2 = _mm_load_ps(r2);
- a = _mm_shuffle_ps(r1, r1, 0xc9);
- b = _mm_shuffle_ps(r2, r2, 0xd2);
+ a = _mm_shuffle_ps(t1, t1, 0xc9);
+ b = _mm_shuffle_ps(t2, t2, 0xd2);
r = _mm_mul_ps( a, b );
- c = _mm_shuffle_ps(r2, r2, 0xc9);
- d = _mm_shuffle_ps(r1, r1, 0xd2);
+ c = _mm_shuffle_ps(t2, t2, 0xc9);
+ d = _mm_shuffle_ps(t1, t1, 0xd2);
a = _mm_mul_ps( c, d );
r = _mm_sub_ps(r,a);
- result = r;
+
+ _mm_store_ps(result, r);
}
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-04-29 23:53:10
|
Revision: 715
http://hgengine.svn.sourceforge.net/hgengine/?rev=715&view=rev
Author: axlecrusher
Date: 2010-04-29 23:53:04 +0000 (Thu, 29 Apr 2010)
Log Message:
-----------
force a hard crash if we run out of memory
Modified Paths:
--------------
Mercury2/src/MercuryMatrix.cpp
Modified: Mercury2/src/MercuryMatrix.cpp
===================================================================
--- Mercury2/src/MercuryMatrix.cpp 2010-04-29 10:50:54 UTC (rev 714)
+++ Mercury2/src/MercuryMatrix.cpp 2010-04-29 23:53:04 UTC (rev 715)
@@ -23,13 +23,14 @@
FloatRow* MercuryMatrixMemory::GetNewMatrix()
{
- MatrixArray* m = (MatrixArray*)0xdeadbeef;
+ MatrixArray* m = (MatrixArray*)0x0;
MSemaphoreLock lock(&m_lock);
if ( m_free.begin() != m_free.end() )
{
m = m_free.front();
m_free.pop_front();
}
+ if (m==0x0) ***m=0;
return (FloatRow*)m;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-04-29 10:51:00
|
Revision: 714
http://hgengine.svn.sourceforge.net/hgengine/?rev=714&view=rev
Author: axlecrusher
Date: 2010-04-29 10:50:54 +0000 (Thu, 29 Apr 2010)
Log Message:
-----------
instance counter for MercuryMatrixMemory singleton
Modified Paths:
--------------
Mercury2/src/MercuryMatrix.cpp
Mercury2/src/MercuryMatrix.h
Modified: Mercury2/src/MercuryMatrix.cpp
===================================================================
--- Mercury2/src/MercuryMatrix.cpp 2010-04-29 10:32:21 UTC (rev 713)
+++ Mercury2/src/MercuryMatrix.cpp 2010-04-29 10:50:54 UTC (rev 714)
@@ -1,7 +1,7 @@
#include "MercuryMatrix.h"
#include <MercuryLog.h>
-MercuryMatrixMemory& MercuryMatrixMemory::Instance()
+MercuryMatrixMemory& MercuryMatrixMemory::GetInstance()
{
static MercuryMatrixMemory* mmm = NULL;
@@ -58,21 +58,21 @@
#endif
*/
// *this = Identity();
- m_matrix = MercuryMatrixMemory::Instance().GetNewMatrix();
+ m_matrix = MercuryMatrixMemory::GetInstance().GetNewMatrix();
LoadIdentity();
}
MercuryMatrix::MercuryMatrix(const MercuryMatrix& m)
:m_matrix(0)
{
- m_matrix = MercuryMatrixMemory::Instance().GetNewMatrix();
+ m_matrix = MercuryMatrixMemory::GetInstance().GetNewMatrix();
Copy16f(m_matrix, m.m_matrix);
}
MercuryMatrix::~MercuryMatrix()
{
if (m_matrix)
- MercuryMatrixMemory::Instance().FreeMatrix( m_matrix );
+ MercuryMatrixMemory::GetInstance().FreeMatrix( m_matrix );
m_matrix = NULL;
}
@@ -90,10 +90,10 @@
void MercuryMatrix::Zero()
{
- ZeroFloatRow( m_matrix[0] );
- ZeroFloatRow( m_matrix[1] );
- ZeroFloatRow( m_matrix[2] );
- ZeroFloatRow( m_matrix[3] );
+ m_matrix[0] = {0,0,0,0};
+ m_matrix[1] = {0,0,0,0};
+ m_matrix[2] = {0,0,0,0};
+ m_matrix[3] = {0,0,0,0};
}
const MercuryMatrix& MercuryMatrix::Identity()
Modified: Mercury2/src/MercuryMatrix.h
===================================================================
--- Mercury2/src/MercuryMatrix.h 2010-04-29 10:32:21 UTC (rev 713)
+++ Mercury2/src/MercuryMatrix.h 2010-04-29 10:50:54 UTC (rev 714)
@@ -18,7 +18,7 @@
free ride into the CPU cache. */
public:
void Init();
- static MercuryMatrixMemory& Instance();
+ static MercuryMatrixMemory& GetInstance();
FloatRow* GetNewMatrix();
void FreeMatrix(FloatRow* m);
private:
@@ -81,6 +81,8 @@
void Print() const;
};
+static InstanceCounter<MercuryMatrixMemory> MMMcounter("MercuryMatrixMemory");
+
#endif
/*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-04-29 10:32:27
|
Revision: 713
http://hgengine.svn.sourceforge.net/hgengine/?rev=713&view=rev
Author: axlecrusher
Date: 2010-04-29 10:32:21 +0000 (Thu, 29 Apr 2010)
Log Message:
-----------
Float row can just be a bunch of floats.
We don't really need __m128 in SSE mode.
Modified Paths:
--------------
Mercury2/src/MercuryMath.h
Modified: Mercury2/src/MercuryMath.h
===================================================================
--- Mercury2/src/MercuryMath.h 2010-04-28 16:45:32 UTC (rev 712)
+++ Mercury2/src/MercuryMath.h 2010-04-29 10:32:21 UTC (rev 713)
@@ -22,6 +22,7 @@
#else
#define PREFETCH(a,sel) ; //prefetch a cache line (64 bytes)
#endif
+/*
VC_ALIGN(16) class FloatRow
{
public:
@@ -39,7 +40,10 @@
__m128 m_floats;
#endif
} CC_ALIGN(16);
+*/
+typedef VC_ALIGN(16) float FloatRow[4] CC_ALIGN(16);
+
#ifdef WIN32
#include <limits>
#define INFINITY (std::numeric_limits<float>::infinity())
@@ -113,7 +117,7 @@
//void Float2FloatRow(const float* f, FloatRow& r);
//void FloatRow2Float(const FloatRow& fr, float* f);
-const FloatRow gfrZero = { { 0.f, 0.f, 0.f, 0.f } };
+const FloatRow gfrZero = { 0.f, 0.f, 0.f, 0.f };
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-04-28 16:45:38
|
Revision: 712
http://hgengine.svn.sourceforge.net/hgengine/?rev=712&view=rev
Author: axlecrusher
Date: 2010-04-28 16:45:32 +0000 (Wed, 28 Apr 2010)
Log Message:
-----------
apparently there is far and near are #define somewhere
Modified Paths:
--------------
Mercury2/src/Frustum.cpp
Modified: Mercury2/src/Frustum.cpp
===================================================================
--- Mercury2/src/Frustum.cpp 2010-04-28 16:27:07 UTC (rev 711)
+++ Mercury2/src/Frustum.cpp 2010-04-28 16:45:32 UTC (rev 712)
@@ -100,11 +100,11 @@
m_fbr = m_planes[PFAR].GetCenter() - (Y * m_fh/2.0f) + (X * m_fw/2.0f);
}
-void Frustum::Ortho(float left, float right, float bottom, float top, float near, float far)
+void Frustum::Ortho(float left, float right, float bottom, float top, float znear, float zfar)
{
float rml = right - left;
float tmb = top - bottom;
- float fmn = far - near;
+ float fmn = zfar - znear;
m_frustum = MercuryMatrix::Identity();
m_frustum[0][0] = 2.0f/rml;
@@ -113,7 +113,7 @@
m_frustum[0][3] = -(right+left)/rml;
m_frustum[1][3] = -(top+bottom)/tmb;
- m_frustum[2][3] = -(far+near)/fmn;
+ m_frustum[2][3] = -(zfar+znear)/fmn;
m_planes[PTOP].Setup(MercuryVertex(rml/2.0f, top, fmn/2.0f), MercuryVector(0,-1,0));
m_planes[PBOTTOM].Setup(MercuryVertex(rml/2.0f, bottom, fmn/2.0f), MercuryVector(0,1,0));
@@ -121,8 +121,8 @@
m_planes[PLEFT].Setup(MercuryVertex(left, tmb/2.0f, fmn/2.0f), MercuryVector(1,0,0));
m_planes[PRIGHT].Setup(MercuryVertex(right, tmb/2.0f, fmn/2.0f), MercuryVector(-1,0,0));
- m_planes[PNEAR].Setup(MercuryVertex(rml/2.0f, tmb/2.0f, near), MercuryVector(0,0,-1));
- m_planes[PFAR].Setup(MercuryVertex(rml/2.0f, tmb/2.0f, far), MercuryVector(0,0,1));
+ m_planes[PNEAR].Setup(MercuryVertex(rml/2.0f, tmb/2.0f, znear), MercuryVector(0,0,-1));
+ m_planes[PFAR].Setup(MercuryVertex(rml/2.0f, tmb/2.0f, zfar), MercuryVector(0,0,1));
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-04-28 16:27:13
|
Revision: 711
http://hgengine.svn.sourceforge.net/hgengine/?rev=711&view=rev
Author: axlecrusher
Date: 2010-04-28 16:27:07 +0000 (Wed, 28 Apr 2010)
Log Message:
-----------
Remove.
This is handled by the asset PreRender. Checking every during every render call was really slowing thing down in windows.
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2010-04-28 09:21:53 UTC (rev 710)
+++ Mercury2/src/Shader.cpp 2010-04-28 16:27:07 UTC (rev 711)
@@ -63,8 +63,6 @@
{
bool bApply = true;
- CheckForNewer();
-
//If there's a currnet shader, we may want to abort switching shaders
if( CurrentShader )
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2010-04-28 09:21:59
|
Revision: 710
http://hgengine.svn.sourceforge.net/hgengine/?rev=710&view=rev
Author: cnlohr
Date: 2010-04-28 09:21:53 +0000 (Wed, 28 Apr 2010)
Log Message:
-----------
tweak Cu2, gotta look into more what could be going on, though
Modified Paths:
--------------
Mercury2/modules/Cu2.cpp
Mercury2/modules/Cu2.h
Modified: Mercury2/modules/Cu2.cpp
===================================================================
--- Mercury2/modules/Cu2.cpp 2010-04-28 09:21:34 UTC (rev 709)
+++ Mercury2/modules/Cu2.cpp 2010-04-28 09:21:53 UTC (rev 710)
@@ -327,6 +327,14 @@
LOAD_FROM_XML( "associatedValue", m_sAssociatedValue, );
LOAD_FROM_XML( "associatedValueSet", m_sAssociatedValueSet, );
+ LOAD_FROM_XML( "associatedValueX", m_sAssociatedValueX, );
+ LOAD_FROM_XML( "associatedValueY", m_sAssociatedValueY, );
+
+ LOAD_FROM_XML( "xRangeMin", m_sxRangeMin, );
+ LOAD_FROM_XML( "xRangeMax", m_sxRangeMax, );
+ LOAD_FROM_XML( "yRangeMin", m_syRangeMin, );
+ LOAD_FROM_XML( "yRangeMax", m_syRangeMax, );
+
if( m_pText )
{
m_pText->SetAlignment( TextNode::LEFT );
@@ -350,7 +358,14 @@
if( m_bAutoSize ) sXMLStream += ssprintf( "autoSize=\"%d\" ", m_bAutoSize );
if( m_sAssociatedValue.length() ) sXMLStream += ssprintf( "associatedValue=\"%s\" ", m_sAssociatedValue.c_str() );
if( m_sAssociatedValueSet.length() ) sXMLStream += ssprintf( "associatedValueSet=\"%s\" ", m_sAssociatedValueSet.c_str() );
+ if( m_sAssociatedValueX.length() ) sXMLStream += ssprintf( "associatedValueX=\"%s\" ", m_sAssociatedValueX.c_str() );
+ if( m_sAssociatedValueY.length() ) sXMLStream += ssprintf( "associatedValueY=\"%s\" ", m_sAssociatedValueY.c_str() );
+ if( m_sxRangeMin.length() ) sXMLStream += ssprintf( "xRangeMin=\"%s\" ",m_sxRangeMin.c_str() );
+ if( m_sxRangeMax.length() ) sXMLStream += ssprintf( "xRangeMax=\"%s\" ",m_sxRangeMax.c_str() );
+ if( m_syRangeMin.length() ) sXMLStream += ssprintf( "yRangeMin=\"%s\" ",m_syRangeMin.c_str() );
+ if( m_syRangeMax.length() ) sXMLStream += ssprintf( "yRangeMax=\"%s\" ",m_syRangeMax.c_str() );
+
if( !m_pText )
m_pText->SaveToXMLTag( sXMLStream );
@@ -361,6 +376,7 @@
{
if( c == PRESS_IN )
m_bDown = true;
+
if( c == RELEASE_IN )
{
if( m_bDown )
@@ -376,6 +392,30 @@
Cu2Element::MouseAction( x, y, c, iWhichButton );
}
+int Cu2Button::MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask )
+{
+ if( m_sAssociatedValueX.length() && m_bDown && x >= 0 && y >= 0 && x < GetW() && y < GetH() )
+ {
+ float fxRangeMin = atof( m_sxRangeMin.c_str() );
+ float fxRangeMax = m_sxRangeMax.length()?atof( m_sxRangeMax.c_str() ):GetW();
+
+ float fX = ( float(x) / float(GetW()-1) ) * (fxRangeMax - fxRangeMin) + fxRangeMin;
+ MESSAGEMAN.GetValue( m_sAssociatedValueX )->SetFloat( fX );
+ }
+
+ if( m_sAssociatedValueY.length() && m_bDown && x >= 0 && y >= 0 && x < GetW() && y < GetH() )
+ {
+ float fyRangeMin = atof( m_syRangeMin.c_str() );
+ float fyRangeMax = m_syRangeMax.length()?atof( m_syRangeMax.c_str() ):GetW();
+
+ float fY = ( float(y) / float(GetH()-1) ) * (fyRangeMax - fyRangeMin) + fyRangeMin;
+ MESSAGEMAN.GetValue( m_sAssociatedValueY )->SetFloat( fY );
+ }
+
+ return Cu2Element::MouseMotion( x, y, iCurrentButtonMask, iLastButtonMask );
+}
+
+
void Cu2Button::Refresh()
{
if( !m_pText )
Modified: Mercury2/modules/Cu2.h
===================================================================
--- Mercury2/modules/Cu2.h 2010-04-28 09:21:34 UTC (rev 709)
+++ Mercury2/modules/Cu2.h 2010-04-28 09:21:53 UTC (rev 710)
@@ -150,6 +150,7 @@
public:
Cu2Button();
+ virtual int MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask );
virtual void MouseAction( int x, int y, Cu2Action c, int iWhichButton );
///This function gets called whenever the button is clicked, you should abstract from this.
virtual void Click( int x, int y );
@@ -172,10 +173,18 @@
private:
MString m_sAssociatedValue;
MString m_sAssociatedValueSet;
+ MString m_sAssociatedValueX;
+ MString m_sAssociatedValueY;
MString m_sMessageToSend;
MString m_sValueToSend;
MString m_sText;
+
+ MString m_sxRangeMin;
+ MString m_sxRangeMax;
+ MString m_syRangeMin;
+ MString m_syRangeMax;
+
bool m_bAutoSize;
bool m_bDown;
TextNode * m_pText;
@@ -238,6 +247,7 @@
MString m_sTitle;
};
+
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2010-04-28 09:21:42
|
Revision: 709
http://hgengine.svn.sourceforge.net/hgengine/?rev=709&view=rev
Author: cnlohr
Date: 2010-04-28 09:21:34 +0000 (Wed, 28 Apr 2010)
Log Message:
-----------
allow access to the base value so we can listen in
Modified Paths:
--------------
Mercury2/src/MercuryValue.h
Modified: Mercury2/src/MercuryValue.h
===================================================================
--- Mercury2/src/MercuryValue.h 2010-04-28 02:26:32 UTC (rev 708)
+++ Mercury2/src/MercuryValue.h 2010-04-28 09:21:34 UTC (rev 709)
@@ -133,6 +133,7 @@
public:
MVRefBase(MValue * m) : mv(m) { MSemaphoreLock( &mv->m_Sema ); mv->m_References++; }
MVRefBase(const MString & sPath); //Special - get values from MESSAGEMAN
+ MValue * Base() { return mv; }
~MVRefBase() {
//If out of references, bail.
mv->m_Sema.Wait();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-04-28 02:26:38
|
Revision: 708
http://hgengine.svn.sourceforge.net/hgengine/?rev=708&view=rev
Author: axlecrusher
Date: 2010-04-28 02:26:32 +0000 (Wed, 28 Apr 2010)
Log Message:
-----------
fix bug
Modified Paths:
--------------
Mercury2/src/MercuryMath.cpp
Modified: Mercury2/src/MercuryMath.cpp
===================================================================
--- Mercury2/src/MercuryMath.cpp 2010-04-28 02:05:26 UTC (rev 707)
+++ Mercury2/src/MercuryMath.cpp 2010-04-28 02:26:32 UTC (rev 708)
@@ -276,7 +276,7 @@
c = _mm_shuffle_ps(r2, r2, 0xc9);
d = _mm_shuffle_ps(r1, r1, 0xd2);
a = _mm_mul_ps( c, d );
- a = _mm_sub_ps(r,a);
+ r = _mm_sub_ps(r,a);
result = r;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-04-28 02:05:32
|
Revision: 707
http://hgengine.svn.sourceforge.net/hgengine/?rev=707&view=rev
Author: axlecrusher
Date: 2010-04-28 02:05:26 +0000 (Wed, 28 Apr 2010)
Log Message:
-----------
preallocate matrix space in one giant chunk.
Modified Paths:
--------------
Mercury2/src/MercuryMatrix.cpp
Mercury2/src/MercuryMatrix.h
Modified: Mercury2/src/MercuryMatrix.cpp
===================================================================
--- Mercury2/src/MercuryMatrix.cpp 2010-04-27 21:39:01 UTC (rev 706)
+++ Mercury2/src/MercuryMatrix.cpp 2010-04-28 02:05:26 UTC (rev 707)
@@ -1,13 +1,52 @@
#include "MercuryMatrix.h"
#include <MercuryLog.h>
+MercuryMatrixMemory& MercuryMatrixMemory::Instance()
+{
+ static MercuryMatrixMemory* mmm = NULL;
+
+ if (mmm==NULL)
+ {
+ mmm = new MercuryMatrixMemory();
+ mmm->Init();
+ }
+
+ return *mmm;
+}
+
+void MercuryMatrixMemory::Init()
+{
+ MSemaphoreLock lock(&m_lock);
+ for (unsigned int i = 0; i < rows;i++)
+ m_free.push_back( m_data+i );
+}
+
+FloatRow* MercuryMatrixMemory::GetNewMatrix()
+{
+ MatrixArray* m = (MatrixArray*)0xdeadbeef;
+ MSemaphoreLock lock(&m_lock);
+ if ( m_free.begin() != m_free.end() )
+ {
+ m = m_free.front();
+ m_free.pop_front();
+ }
+ return (FloatRow*)m;
+}
+
+void MercuryMatrixMemory::FreeMatrix(FloatRow* m)
+{
+ MSemaphoreLock lock(&m_lock);
+ m_free.push_back((MatrixArray*)m);
+}
+/*
VC_ALIGN(16) float base_matrix_identity[16] CC_ALIGN(16) = {
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f };
-
+*/
MercuryMatrix::MercuryMatrix()
+ :m_matrix(0)
{/*
#ifdef USE_SSE
m_matrix[0] = _mm_load1_ps( &base_matrix_identity[0] );
@@ -19,9 +58,24 @@
#endif
*/
// *this = Identity();
+ m_matrix = MercuryMatrixMemory::Instance().GetNewMatrix();
LoadIdentity();
}
+MercuryMatrix::MercuryMatrix(const MercuryMatrix& m)
+ :m_matrix(0)
+{
+ m_matrix = MercuryMatrixMemory::Instance().GetNewMatrix();
+ Copy16f(m_matrix, m.m_matrix);
+}
+
+MercuryMatrix::~MercuryMatrix()
+{
+ if (m_matrix)
+ MercuryMatrixMemory::Instance().FreeMatrix( m_matrix );
+ m_matrix = NULL;
+}
+
const MercuryMatrix& MercuryMatrix::operator=(const MercuryMatrix& m)
{
Copy16f(m_matrix, m.m_matrix);
@@ -44,7 +98,8 @@
const MercuryMatrix& MercuryMatrix::Identity()
{
- static bool bSetIdentity = false;
+ return IdentityMatrix;
+/* static bool bSetIdentity = false;
if (!bSetIdentity)
{
@@ -60,11 +115,14 @@
}
return IdentityMatrix;
+ */
}
void MercuryMatrix::LoadIdentity()
{
- Copy16f(m_matrix, base_matrix_identity );
+ for (uint8_t x=0;x<4;++x)
+ for (uint8_t y=0;y<4;++y)
+ m_matrix[x][y] = (x==y)?1.0f:0.0f;
}
void MercuryMatrix::Translate(float x, float y, float z)
Modified: Mercury2/src/MercuryMatrix.h
===================================================================
--- Mercury2/src/MercuryMatrix.h 2010-04-27 21:39:01 UTC (rev 706)
+++ Mercury2/src/MercuryMatrix.h 2010-04-28 02:05:26 UTC (rev 707)
@@ -7,25 +7,49 @@
#include <MercuryVertex.h>
#include <MQuaternion.h>
+#include <list>
+#include <MSemaphore.h>
+
+///Memory holder for matrices
+class MercuryMatrixMemory
+{
+ /* Allocates all matrix space as one contigous block
+ to try to take advantage of data prefetching. Some matrix data should get a
+ free ride into the CPU cache. */
+ public:
+ void Init();
+ static MercuryMatrixMemory& Instance();
+ FloatRow* GetNewMatrix();
+ void FreeMatrix(FloatRow* m);
+ private:
+ typedef FloatRow MatrixArray[4]; //64kb
+ static const unsigned int rows = 1024; //1024 matrices * 64bytes each = 64kb
+ std::list< MatrixArray* > m_free;
+ MatrixArray m_data[rows];
+ MSemaphore m_lock;
+};
+
///General Purpose 4x4 row-major matrix
- VC_ALIGN(16) class MercuryMatrix
+class MercuryMatrix
{
private:
///[row][column] (The internal matrix)
// float m_matrix[4][4];
- FloatRow m_matrix[4];
+// FloatRow m_matrix[4];
+ FloatRow* m_matrix;
static MercuryMatrix IdentityMatrix;
public:
MercuryMatrix();
- inline MercuryMatrix(const MercuryMatrix& m) { *this = m; }
- inline float* operator[](unsigned int i) { return (float*)&m_matrix[i]; }
+ MercuryMatrix(const MercuryMatrix& m);
+ ~MercuryMatrix();
+ inline float* operator[](unsigned int i) { return m_matrix[i]; }
///Allow typecasting to float * for use in APIs
- inline const float* operator[](unsigned int i) const { return (float*)&m_matrix[i]; }
+ inline const float* operator[](unsigned int i) const { return m_matrix[i]; }
const MercuryMatrix& operator=(const MercuryMatrix& m);
const MercuryMatrix& operator=(const float* m);
- inline float* Ptr() { return (float*)&m_matrix; }
- inline const float* Ptr() const { return (float*)&m_matrix; }
+ inline float* Ptr() { return (float*)m_matrix; }
+ inline const float* Ptr() const { return (const float*)m_matrix; }
MercuryMatrix operator*(const MercuryMatrix& m) const;
MercuryMatrix& operator*=(const MercuryMatrix& m);
@@ -55,13 +79,8 @@
void LoadIdentity();
void Print() const;
-} CC_ALIGN(16);
+};
-//namespace MercuryMath
-//{
-//}
-
-
#endif
/*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-04-27 21:39:07
|
Revision: 706
http://hgengine.svn.sourceforge.net/hgengine/?rev=706&view=rev
Author: axlecrusher
Date: 2010-04-27 21:39:01 +0000 (Tue, 27 Apr 2010)
Log Message:
-----------
forgot to commit
Modified Paths:
--------------
Mercury2/modules/TextNode.cpp
Modified: Mercury2/modules/TextNode.cpp
===================================================================
--- Mercury2/modules/TextNode.cpp 2010-04-27 18:20:41 UTC (rev 705)
+++ Mercury2/modules/TextNode.cpp 2010-04-27 21:39:01 UTC (rev 706)
@@ -22,7 +22,7 @@
m_bShiftAbsolute(false)
{
//Disabling saving of children... As, we create many temporary children.
- m_bEnableSaveChildren = false;
+ SetSaveChildren(false);
}
void TextNode::Update(float dTime)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-04-27 18:20:49
|
Revision: 705
http://hgengine.svn.sourceforge.net/hgengine/?rev=705&view=rev
Author: axlecrusher
Date: 2010-04-27 18:20:41 +0000 (Tue, 27 Apr 2010)
Log Message:
-----------
visual studio and GCC Alignment
Modified Paths:
--------------
Mercury2/src/MQuaternion.h
Mercury2/src/MercuryMath.h
Mercury2/src/MercuryMatrix.cpp
Mercury2/src/MercuryMatrix.h
Mercury2/src/MercuryUtil.h
Modified: Mercury2/src/MQuaternion.h
===================================================================
--- Mercury2/src/MQuaternion.h 2010-04-27 18:16:51 UTC (rev 704)
+++ Mercury2/src/MQuaternion.h 2010-04-27 18:20:41 UTC (rev 705)
@@ -7,7 +7,7 @@
class MercuryMatrix;
///Mathematical Quaternion (Used for Rotation)
-class MQuaternion {
+VC_ALIGN(16) class MQuaternion {
public:
enum WXYZ { QW = 0, QX, QY, QZ };
@@ -81,7 +81,7 @@
//Also, for most operations, it appeared to go slower. All the moving in and out of these variables
//is disadvantagious.
float m_wxyz[4];
-} M_ALIGN(32);
+} CC_ALIGN(16);
///Produce a matrix out of a rotation x, then y then z (how Mercury does it)
void AngleMatrix (const MercuryVector & angles, MercuryMatrix & mat );
Modified: Mercury2/src/MercuryMath.h
===================================================================
--- Mercury2/src/MercuryMath.h 2010-04-27 18:16:51 UTC (rev 704)
+++ Mercury2/src/MercuryMath.h 2010-04-27 18:20:41 UTC (rev 705)
@@ -1,5 +1,5 @@
#ifndef _MERCURYMATH_H
-#define _MERCURYMATH_H
+#define _MERCURYMATH_H
#include <math.h>
#ifdef HGENGINE
@@ -8,13 +8,21 @@
#endif
#endif
+#if defined(__GNUC__)
+#define VC_ALIGN(n)
+#define CC_ALIGN(n) __attribute__((aligned(n)))
+#else
+#define VC_ALIGN(n) __declspec(align(n))
+#define CC_ALIGN(n)
+#endif
+
#ifdef USE_SSE
#include <xmmintrin.h>
#define PREFETCH(a,sel) _mm_prefetch(a,sel); //prefetch a cache line (64 bytes)
#else
#define PREFETCH(a,sel) ; //prefetch a cache line (64 bytes)
#endif
-class FloatRow
+VC_ALIGN(16) class FloatRow
{
public:
inline operator float*() { return (float*)&m_floats; }
@@ -27,9 +35,10 @@
inline operator __m128&() { return m_floats; }
inline operator const __m128&() const { return m_floats; }
- __m128 m_floats __attribute__((aligned(16)));
+// __m128 m_floats __attribute__((aligned(16)));
+ __m128 m_floats;
#endif
-};
+} CC_ALIGN(16);
#ifdef WIN32
#include <limits>
@@ -99,7 +108,7 @@
//http://graphics.stanford.edu/~seander/bithacks.html
#define SetBit(x,mask,t) ((x & ~mask) | (-t & mask)) /*superscalar CPU version*/
-#define GetBit(x,mask) (x & mask)
+#define GetBit(x,mask) ((x & mask)>0)
//void Float2FloatRow(const float* f, FloatRow& r);
//void FloatRow2Float(const FloatRow& fr, float* f);
Modified: Mercury2/src/MercuryMatrix.cpp
===================================================================
--- Mercury2/src/MercuryMatrix.cpp 2010-04-27 18:16:51 UTC (rev 704)
+++ Mercury2/src/MercuryMatrix.cpp 2010-04-27 18:20:41 UTC (rev 705)
@@ -1,7 +1,7 @@
#include "MercuryMatrix.h"
#include <MercuryLog.h>
-float base_matrix_identity[16] = {
+VC_ALIGN(16) float base_matrix_identity[16] CC_ALIGN(16) = {
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
@@ -18,7 +18,8 @@
Copy16f(m_matrix[0], base_matrix_identity );
#endif
*/
- *this = Identity();
+// *this = Identity();
+ LoadIdentity();
}
const MercuryMatrix& MercuryMatrix::operator=(const MercuryMatrix& m)
@@ -61,6 +62,11 @@
return IdentityMatrix;
}
+void MercuryMatrix::LoadIdentity()
+{
+ Copy16f(m_matrix, base_matrix_identity );
+}
+
void MercuryMatrix::Translate(float x, float y, float z)
{
MercuryMatrix m;
Modified: Mercury2/src/MercuryMatrix.h
===================================================================
--- Mercury2/src/MercuryMatrix.h 2010-04-27 18:16:51 UTC (rev 704)
+++ Mercury2/src/MercuryMatrix.h 2010-04-27 18:20:41 UTC (rev 705)
@@ -8,7 +8,7 @@
#include <MQuaternion.h>
///General Purpose 4x4 row-major matrix
-class MercuryMatrix
+ VC_ALIGN(16) class MercuryMatrix
{
private:
///[row][column] (The internal matrix)
@@ -52,14 +52,10 @@
void Zero();
static const MercuryMatrix& Identity();
+ void LoadIdentity();
void Print() const;
-}
-#if !defined( WIN32 ) || defined( _MSC_VER )
-M_ALIGN(64);
-#else
-M_ALIGN(16);
-#endif
+} CC_ALIGN(16);
//namespace MercuryMath
//{
Modified: Mercury2/src/MercuryUtil.h
===================================================================
--- Mercury2/src/MercuryUtil.h 2010-04-27 18:16:51 UTC (rev 704)
+++ Mercury2/src/MercuryUtil.h 2010-04-27 18:20:41 UTC (rev 705)
@@ -19,12 +19,6 @@
void* mmemalign(size_t align, size_t size, void*& mem);
bool isAligned(size_t align, const void* mem);
-#if defined(__GNUC__)
-#define M_ALIGN(n) __attribute__((aligned(n)))
-#else
-#define M_ALIGN(n)
-#endif
-
///Make a string all upper case
MString ToUpper(const MString & s);
@@ -96,10 +90,10 @@
///Open up filename: sFileName and dump it into a new buffer; you must delete the return value when done.
///The return value is -1 if there was an issue, otherwise it is valid.
long FileToString( const MString & sFileName, char * & data );
-
-///Take a string and write it to the hard drive as a file. True indicates everything is okay.
-bool StringToFile( const MString & sFileName, const MString & data );
+///Take a string and write it to the hard drive as a file. True indicates everything is okay.
+bool StringToFile( const MString & sFileName, const MString & data );
+
/* These two functions are very different */
/// nextPow2 will go to the NEXT power of 2 even if x is already a power of 2.
inline int nextPow2(int x) { int num = 1; while(num <= x) num <<= 1; return num; }
@@ -135,20 +129,20 @@
MString ConvertToUnformatted( const MString & cf );
///millisecond sleep
-void msleep(uint32_t msec);
-
-///Utility linear function, in = [0..1] out = [0..1]; respectively, if slice >= 1
-float FLinear( float in, float slice = 1. );
-
-///Utility exponential function, in = [0..1] out = [0..1]; respectively; regardless of pow. If pow == 1, would be identical to linear.
-float FExponential( float in, float powx = 1. );
-
-///Utility step function; out = 0 when in < stepplace; out = 1 when in >= stepplace
-float FStep( float in, float stepplace = 1. );
-
-///Utility sigmoid function; in = [0..1] out = [0..1]; speed is the slope of change in the middle.
-float FSigmoid( float in, float fspeed = 1. );
+void msleep(uint32_t msec);
+///Utility linear function, in = [0..1] out = [0..1]; respectively, if slice >= 1
+float FLinear( float in, float slice = 1. );
+
+///Utility exponential function, in = [0..1] out = [0..1]; respectively; regardless of pow. If pow == 1, would be identical to linear.
+float FExponential( float in, float powx = 1. );
+
+///Utility step function; out = 0 when in < stepplace; out = 1 when in >= stepplace
+float FStep( float in, float stepplace = 1. );
+
+///Utility sigmoid function; in = [0..1] out = [0..1]; speed is the slope of change in the middle.
+float FSigmoid( float in, float fspeed = 1. );
+
#endif
/* Copyright (c) 2009, Joshua Allen and Charles Lohr
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-04-27 18:16:57
|
Revision: 704
http://hgengine.svn.sourceforge.net/hgengine/?rev=704&view=rev
Author: axlecrusher
Date: 2010-04-27 18:16:51 +0000 (Tue, 27 Apr 2010)
Log Message:
-----------
const reference
Modified Paths:
--------------
Mercury2/src/MQuaternion.cpp
Modified: Mercury2/src/MQuaternion.cpp
===================================================================
--- Mercury2/src/MQuaternion.cpp 2010-04-27 18:16:10 UTC (rev 703)
+++ Mercury2/src/MQuaternion.cpp 2010-04-27 18:16:51 UTC (rev 704)
@@ -275,7 +275,7 @@
}
//Returns the Euclidian Outer Product of two MQuaternions
-MercuryVertex outerProduct(MQuaternion a,MQuaternion b)
+MercuryVertex outerProduct(const MQuaternion& a, const MQuaternion& b)
{
MercuryVertex result;
result[0] = (a.m_wxyz[0]*b.m_wxyz[1])-(a.m_wxyz[1]*b.m_wxyz[0])-(a.m_wxyz[2]*b.m_wxyz[3])+(a.m_wxyz[3]*b.m_wxyz[2]);
@@ -285,7 +285,7 @@
}
//Returns the Even Product of two MQuaternions
-MQuaternion evenProduct(MQuaternion a,MQuaternion b) {
+MQuaternion evenProduct(const MQuaternion& a, const MQuaternion& b) {
MQuaternion result;
result.m_wxyz[0] = (a.m_wxyz[0]*b.m_wxyz[0])-(a.m_wxyz[1]*b.m_wxyz[1])-(a.m_wxyz[2]*b.m_wxyz[2])-(a.m_wxyz[3]*b.m_wxyz[3]);
result.m_wxyz[1] = (a.m_wxyz[0]*b.m_wxyz[1])+(a.m_wxyz[1]*b.m_wxyz[0]);
@@ -295,7 +295,7 @@
}
//Returns the Odd Product of two MQuaternions (Similar to Vector Cross-Product)
-MercuryVertex oddProduct(MQuaternion a,MQuaternion b) {
+MercuryVertex oddProduct(const MQuaternion& a, const MQuaternion& b) {
MercuryVertex result;
result[0] = (a.m_wxyz[2]*b.m_wxyz[3])-(a.m_wxyz[3]*b.m_wxyz[2]);
result[1] = (a.m_wxyz[3]*b.m_wxyz[1])-(a.m_wxyz[1]*b.m_wxyz[3]);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-04-27 18:16:19
|
Revision: 703
http://hgengine.svn.sourceforge.net/hgengine/?rev=703&view=rev
Author: axlecrusher
Date: 2010-04-27 18:16:10 +0000 (Tue, 27 Apr 2010)
Log Message:
-----------
fix windows compile
Modified Paths:
--------------
Mercury2/src/MercuryMath.cpp
Modified: Mercury2/src/MercuryMath.cpp
===================================================================
--- Mercury2/src/MercuryMath.cpp 2010-04-27 00:16:04 UTC (rev 702)
+++ Mercury2/src/MercuryMath.cpp 2010-04-27 18:16:10 UTC (rev 703)
@@ -275,7 +275,8 @@
c = _mm_shuffle_ps(r2, r2, 0xc9);
d = _mm_shuffle_ps(r1, r1, 0xd2);
- r -= _mm_mul_ps( c, d );
+ a = _mm_mul_ps( c, d );
+ a = _mm_sub_ps(r,a);
result = r;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-04-27 00:16:12
|
Revision: 702
http://hgengine.svn.sourceforge.net/hgengine/?rev=702&view=rev
Author: axlecrusher
Date: 2010-04-27 00:16:04 +0000 (Tue, 27 Apr 2010)
Log Message:
-----------
Convert boolean variables into bitwise flags to cut down on memory use.
Modified Paths:
--------------
Mercury2/src/MercuryMath.h
Mercury2/src/MercuryNode.cpp
Mercury2/src/MercuryNode.h
Modified: Mercury2/src/MercuryMath.h
===================================================================
--- Mercury2/src/MercuryMath.h 2010-04-26 02:41:10 UTC (rev 701)
+++ Mercury2/src/MercuryMath.h 2010-04-27 00:16:04 UTC (rev 702)
@@ -97,6 +97,10 @@
void TransposeMatrix( FloatRow* m );
void MMCrossProduct( const FloatRow& r1, const FloatRow& r2, FloatRow& result);
+//http://graphics.stanford.edu/~seander/bithacks.html
+#define SetBit(x,mask,t) ((x & ~mask) | (-t & mask)) /*superscalar CPU version*/
+#define GetBit(x,mask) (x & mask)
+
//void Float2FloatRow(const float* f, FloatRow& r);
//void FloatRow2Float(const FloatRow& fr, float* f);
Modified: Mercury2/src/MercuryNode.cpp
===================================================================
--- Mercury2/src/MercuryNode.cpp 2010-04-26 02:41:10 UTC (rev 701)
+++ Mercury2/src/MercuryNode.cpp 2010-04-27 00:16:04 UTC (rev 702)
@@ -17,9 +17,7 @@
MercuryNode::MercuryNode()
:m_parent(NULL), m_prevSibling(NULL),
- m_nextSibling(NULL), m_hidden(false),
- m_useAlphaPath(false), m_culled(false),
- m_bEnableSave(true), m_bEnableSaveChildren(true),
+ m_nextSibling(NULL), m_flags(SAVECHILDREN & ENABLESAVE),
m_iPasses( DEFAULT_PASSES ), m_iForcePasses( 0 )
{
m_pGlobalMatrix = &MercuryMatrix::Identity();
@@ -213,7 +211,7 @@
for (MercuryNode* child = FirstChild(); child != NULL; child = NextChild(child))
{
child->RecursivePreRender();
- m_culled = m_culled && child->IsCulled();
+ SetCulled( IsCulled() && child->IsCulled() );
}
}
@@ -254,7 +252,7 @@
//call render on other render graph entries under me
for (MercuryNode* child = FirstChild(); child != NULL; child = NextChild(child))
{
- if ( child->m_useAlphaPath )
+ if ( child->GetUseAlphaPass() )
CURRENTRENDERGRAPH->AddAlphaNode(child);
else
child->RecursiveRender();
@@ -284,10 +282,12 @@
{
SetName( node.Attribute("name") );
- LOAD_FROM_XML( "hidden", m_hidden, StrToBool );
- LOAD_FROM_XML( "alphaPath", m_useAlphaPath, StrToBool );
- LOAD_FROM_XML( "enableSave", m_bEnableSave, StrToBool );
- LOAD_FROM_XML( "enableSaveChildren", m_bEnableSaveChildren, StrToBool );
+ bool t;
+ t = IsHidden(); LOAD_FROM_XML( "hidden", t, StrToBool ); SetHidden(t);
+ t = GetUseAlphaPass(); LOAD_FROM_XML( "alphaPath", t, StrToBool ); SetUseAlphaPass(t);
+ t = GetEnableSave(); LOAD_FROM_XML( "enableSave", t, StrToBool ); SetEnableSave(t);
+ t = GetSaveChildren(); LOAD_FROM_XML( "enableSaveChildren", t, StrToBool );
+ SetSaveChildren(t);
//Not much to do here except run through all the children nodes
@@ -324,7 +324,7 @@
void MercuryNode::SaveToXML( MString & sXMLStream, int depth )
{
- if( !m_bEnableSave ) return;
+ if( !GetEnableSave() ) return;
sXMLStream += ssprintf( "%*c<node ", depth * 3, 32 );
SaveBaseXMLTag( sXMLStream );
@@ -332,7 +332,7 @@
bool bNoChildren = true;
- if( m_bEnableSaveChildren )
+ if( GetSaveChildren() )
{
if( !m_assets.empty() )
{
@@ -350,7 +350,7 @@
//No children yet (but we have them, so terminate (>) )
for( std::list< MercuryNode * >::iterator i = m_children.begin(); i != m_children.end(); i++ )
{
- if( (*i)->m_bEnableSave )
+ if( (*i)->GetEnableSave() )
{
if( bNoChildren )
sXMLStream += ">\n";
@@ -377,7 +377,7 @@
sXMLStream+= ssprintf( "type=\"%s\" ", GetType() );
if( GetName().length() )
sXMLStream += ssprintf( "name=\"%s\" ", GetName().c_str() );
- if( m_useAlphaPath )
+ if( GetUseAlphaPass() )
sXMLStream += "alphaPath=\"true\" ";
}
Modified: Mercury2/src/MercuryNode.h
===================================================================
--- Mercury2/src/MercuryNode.h 2010-04-26 02:41:10 UTC (rev 701)
+++ Mercury2/src/MercuryNode.h 2010-04-27 00:16:04 UTC (rev 702)
@@ -28,6 +28,15 @@
///The Global Pass Number (which Pass is currently doing Render)
extern __ThreadLocalStore int g_iPass;
+enum MercuryNodeFlagMask
+{
+ HIDDEN = 1,
+ CULLED,
+ SAVECHILDREN,
+ ENABLESAVE,
+ ALPHAPATH
+};
+
class MercuryNode : public MessageHandler
{
public:
@@ -114,10 +123,21 @@
virtual void Render(const MercuryMatrix& matrix);
virtual void PostRender(const MercuryMatrix& matrix);
- inline bool IsHidden() { return m_hidden; }
+ virtual void SetHidden( bool bHide ) { m_flags = SetBit(m_flags,HIDDEN,bHide); } //is there anyway to make this not virtual??
+ inline bool IsHidden() { return GetBit(m_flags,HIDDEN); }
- inline void SetCulled(bool t) { m_culled = t; }
- inline bool IsCulled() const { return m_culled; }
+ inline void SetCulled(bool t) { m_flags = SetBit(m_flags,CULLED,t); }
+ inline bool IsCulled() const { return GetBit(m_flags,CULLED); }
+
+ inline void SetSaveChildren(bool t) { m_flags = SetBit(m_flags,SAVECHILDREN,t); }
+ inline bool GetSaveChildren() const { return GetBit(m_flags,SAVECHILDREN); }
+
+ inline void SetEnableSave(bool t) { m_flags = SetBit(m_flags,ENABLESAVE,t); }
+ inline bool GetEnableSave() const { return GetBit(m_flags,ENABLESAVE); }
+
+ inline void SetUseAlphaPass(bool t) { m_flags = SetBit(m_flags,ALPHAPATH,t); }
+ inline bool GetUseAlphaPass() const { return GetBit(m_flags,ALPHAPATH); }
+
virtual MercuryMatrix ManipulateMatrix(const MercuryMatrix& matrix);
const MercuryMatrix & GetGlobalMatrix() const { return m_pGlobalMatrix[g_iViewportID]; }
@@ -125,7 +145,6 @@
inline unsigned short GetPasses() const { return m_iPasses; }
- virtual void SetHidden( bool bHide ) { m_hidden = bHide; }
protected:
std::list< MercuryNode* > m_children; //These nodes are unique, not instanced
MercuryNode* m_parent;
@@ -135,11 +154,7 @@
static bool m_rebuildRenderGraph;
MString m_name;
- bool m_hidden;
- bool m_useAlphaPath;
- bool m_culled;
- bool m_bEnableSave;
- bool m_bEnableSaveChildren;
+ unsigned char m_flags;
bool IsInAssetList(MercuryAsset* asset) const;
unsigned short m_iPasses;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-04-26 02:41:16
|
Revision: 701
http://hgengine.svn.sourceforge.net/hgengine/?rev=701&view=rev
Author: axlecrusher
Date: 2010-04-26 02:41:10 +0000 (Mon, 26 Apr 2010)
Log Message:
-----------
fix ambiguous warnings
Modified Paths:
--------------
Mercury2/src/MercuryMath.cpp
Mercury2/src/MercuryMath.h
Modified: Mercury2/src/MercuryMath.cpp
===================================================================
--- Mercury2/src/MercuryMath.cpp 2010-04-25 22:33:57 UTC (rev 700)
+++ Mercury2/src/MercuryMath.cpp 2010-04-26 02:41:10 UTC (rev 701)
@@ -205,7 +205,11 @@
{
unsigned int y;
__m128 xmm[4];
-
+
+// PREFETCH(in1, _MM_HINT_T0);
+// PREFETCH(in2, _MM_HINT_T1);
+// PREFETCH(out, _MM_HINT_T1);
+
for (y = 0; y < 4; ++y)
{
//load rows as columns
Modified: Mercury2/src/MercuryMath.h
===================================================================
--- Mercury2/src/MercuryMath.h 2010-04-25 22:33:57 UTC (rev 700)
+++ Mercury2/src/MercuryMath.h 2010-04-26 02:41:10 UTC (rev 701)
@@ -10,13 +10,13 @@
#ifdef USE_SSE
#include <xmmintrin.h>
+#define PREFETCH(a,sel) _mm_prefetch(a,sel); //prefetch a cache line (64 bytes)
+#else
+#define PREFETCH(a,sel) ; //prefetch a cache line (64 bytes)
#endif
class FloatRow
{
public:
- inline float& operator[](unsigned int i) { return ((float*)&m_floats)[i]; }
- inline const float& operator[](unsigned int i) const { return ((const float*)&m_floats)[i]; }
-
inline operator float*() { return (float*)&m_floats; }
inline operator const float*() const { return (const float*)&m_floats; }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-04-25 22:34:03
|
Revision: 700
http://hgengine.svn.sourceforge.net/hgengine/?rev=700&view=rev
Author: axlecrusher
Date: 2010-04-25 22:33:57 +0000 (Sun, 25 Apr 2010)
Log Message:
-----------
proper command for copying data with SSE. It tries to avoid polluting caches
Modified Paths:
--------------
Mercury2/src/MercuryMath.cpp
Modified: Mercury2/src/MercuryMath.cpp
===================================================================
--- Mercury2/src/MercuryMath.cpp 2010-04-25 20:16:49 UTC (rev 699)
+++ Mercury2/src/MercuryMath.cpp 2010-04-25 22:33:57 UTC (rev 700)
@@ -184,38 +184,21 @@
void Copy4f( void * dest, const void * source )
{
- __m128 xmm;
-
- xmm = _mm_load_ps((float*)source);
- _mm_store_ps((float*)dest, xmm);
+ _mm_stream_ps(((float*)dest),((__m128*)source)[0]);
}
void Copy8f( void * dest, const void * source )
{
- __m128 xmm[2];
-
- xmm[0] = _mm_load_ps((float*)source);
- _mm_store_ps((float*)dest, xmm[0]);
-
- xmm[1] = _mm_load_ps((float*)&(((float*)source)[4]));
- _mm_store_ps((float*)&(((float*)dest)[4]), xmm[1]);
+ _mm_stream_ps(((float*)dest),((__m128*)source)[0]);
+ _mm_stream_ps(((float*)dest)+4,((__m128*)source)[1]);
}
void Copy16f( void * dest, const void * source )
{
- __m128 xmm[4];
-
- xmm[0] = _mm_load_ps((float*)source);
- _mm_store_ps((float*)dest, xmm[0]);
-
- xmm[1] = _mm_load_ps((float*)&(((float*)source)[4]));
- _mm_store_ps((float*)&(((float*)dest)[4]), xmm[1]);
-
- xmm[2] = _mm_load_ps((float*)&(((float*)source)[8]));
- _mm_store_ps((float*)&(((float*)dest)[8]), xmm[2]);
-
- xmm[3] = _mm_load_ps((float*)&(((float*)source)[12]));
- _mm_store_ps((float*)&(((float*)dest)[12]), xmm[3]);
+ _mm_stream_ps(((float*)dest),((__m128*)source)[0]);
+ _mm_stream_ps(((float*)dest)+4,((__m128*)source)[1]);
+ _mm_stream_ps(((float*)dest)+8,((__m128*)source)[2]);
+ _mm_stream_ps(((float*)dest)+12,((__m128*)source)[3]);
}
void MatrixMultiply4f( const FloatRow* in1, const FloatRow* in2, FloatRow* out)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2010-04-25 20:16:58
|
Revision: 699
http://hgengine.svn.sourceforge.net/hgengine/?rev=699&view=rev
Author: cnlohr
Date: 2010-04-25 20:16:49 +0000 (Sun, 25 Apr 2010)
Log Message:
-----------
Fix Mercury, Win32.
Modified Paths:
--------------
Mercury2/Mercury2.vcproj
Mercury2/src/FullscreenQuad.cpp
Mercury2/src/GLHelpers.cpp
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryAsset.cpp
Mercury2/src/MercuryFBO.cpp
Mercury2/src/MercurySound.h
Mercury2/src/Win32Window.cpp
Mercury2/src/Win32Window.h
Modified: Mercury2/Mercury2.vcproj
===================================================================
--- Mercury2/Mercury2.vcproj 2010-04-25 19:42:25 UTC (rev 698)
+++ Mercury2/Mercury2.vcproj 2010-04-25 20:16:49 UTC (rev 699)
@@ -42,7 +42,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="modules;.;src;src/include;src/include/png;src/include/zlib;src/DataStructures;src/DataTypes"
- PreprocessorDefinitions="HGENGINE;WIN32;_CRT_SECURE_NO_WARNINGS"
+ PreprocessorDefinitions="HGENGINE;WIN32;_CRT_SECURE_NO_WARNINGS;_HAVE_LIB_GL"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -115,7 +115,7 @@
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=".;src;src/include;src/include/png;src/include/zlib"
- PreprocessorDefinitions="HGENGINE;WIN32;_CRT_SECURE_NO_WARNINGS"
+ PreprocessorDefinitions="HGENGINE;WIN32;_CRT_SECURE_NO_WARNINGS;_HAVE_LIB_GL"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Modified: Mercury2/src/FullscreenQuad.cpp
===================================================================
--- Mercury2/src/FullscreenQuad.cpp 2010-04-25 19:42:25 UTC (rev 698)
+++ Mercury2/src/FullscreenQuad.cpp 2010-04-25 20:16:49 UTC (rev 699)
@@ -7,7 +7,7 @@
: Quad( key, bInstanced )
{
m_matrix = MercuryMatrix::Identity();
- m_matrix.Transotale(0,0,-1,0,0,0,2,2,0.01);
+ m_matrix.Transotale(0,0,-1,0,0,0,2,2,0.01f);
// m_matrix.Scale(2,2,1);
m_matrix.Transpose();
}
Modified: Mercury2/src/GLHelpers.cpp
===================================================================
--- Mercury2/src/GLHelpers.cpp 2010-04-25 19:42:25 UTC (rev 698)
+++ Mercury2/src/GLHelpers.cpp 2010-04-25 20:16:49 UTC (rev 699)
@@ -111,13 +111,13 @@
modelview, projection, viewport,
&dox, &doy, &doz);
- p = MercuryVertex( dox, doy, doz );
+ p = MercuryVertex( (float)dox, (float)doy, (float)doz );
gluUnProject(
winX, winY, 1,
modelview, projection, viewport,
&dox, &doy, &doz );
- r = MercuryVertex( dox, doy, doz ) - p;
+ r = MercuryVertex( (float)dox, (float)doy, (float)doz ) - p;
r.NormalizeSelf();
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2010-04-25 19:42:25 UTC (rev 698)
+++ Mercury2/src/Mercury2.cpp 2010-04-25 20:16:49 UTC (rev 699)
@@ -15,9 +15,9 @@
#include <MercuryTimer.h>
#include <RenderGraph.h>
#include <Texture.h>
-#ifdef _HAVE_LIB_GL
+#ifdef _HAVE_LIB_GL
#include <GLHeaders.h>
-#endif
+#endif
#include <ModuleManager.h>
#include <MercuryFile.h>
@@ -202,10 +202,10 @@
//uncomment the next 2 lines to use threads
// UpdateLoopGo.Increment();
// updateThread.Wait();
-
+
#ifdef _HAVE_LIB_GL
PrintGLFunctionCalls();
-#endif
+#endif
SAFE_DELETE(root);
SAFE_DELETE(w);
Modified: Mercury2/src/MercuryAsset.cpp
===================================================================
--- Mercury2/src/MercuryAsset.cpp 2010-04-25 19:42:25 UTC (rev 698)
+++ Mercury2/src/MercuryAsset.cpp 2010-04-25 20:16:49 UTC (rev 699)
@@ -55,7 +55,7 @@
void MercuryAsset::PreRender(const MercuryNode* node)
{
- uint32_t t = time(0);
+ uint32_t t = (uint32_t)time(0);
if ( m_lastNewerCheck < t )
{
m_lastNewerCheck = t;
Modified: Mercury2/src/MercuryFBO.cpp
===================================================================
--- Mercury2/src/MercuryFBO.cpp 2010-04-25 19:42:25 UTC (rev 698)
+++ Mercury2/src/MercuryFBO.cpp 2010-04-25 20:16:49 UTC (rev 699)
@@ -95,7 +95,7 @@
int h = MercuryWindow::GetCurrentWindow()->Height();
if ((m_width != w) || (m_height != h))
{
- m_width = w; m_height = h;
+ m_width = (unsigned short) w; m_height = (unsigned short)h;
for (uint8_t i = 0; i < m_numTextures; ++i)
{
MString n = ssprintf("%s_%d", m_name.c_str(), i);
@@ -153,16 +153,16 @@
void MercuryFBO::LoadFromXML(const XMLNode& node)
{
if ( !node.Attribute("width").empty() )
- SetWidth( StrToInt(node.Attribute("width")) );
+ SetWidth( (unsigned short) StrToInt(node.Attribute("width")) );
if ( !node.Attribute("height").empty() )
- SetHeight( StrToInt(node.Attribute("height")) );
+ SetHeight( (unsigned short) StrToInt(node.Attribute("height")) );
if ( !node.Attribute("depth").empty() )
SetUseDepth( node.Attribute("depth") == "true"?true:false );
if ( !node.Attribute("tnum").empty() )
- SetNumTextures( StrToInt(node.Attribute("tnum")) );
+ SetNumTextures( (unsigned char)StrToInt(node.Attribute("tnum")) );
if ( !node.Attribute("usescreensize").empty() )
m_useScreenSize = node.Attribute("usescreensize") == "true"?true:false;
Modified: Mercury2/src/MercurySound.h
===================================================================
--- Mercury2/src/MercurySound.h 2010-04-25 19:42:25 UTC (rev 698)
+++ Mercury2/src/MercurySound.h 2010-04-25 20:16:49 UTC (rev 699)
@@ -70,8 +70,8 @@
//Useful tools
- inline float GetSecondsSinceLastFrame() { float tr = m_tLastTrip.Age(); return (tr>1.)?1.:tr; }
- inline unsigned int SamplesSinceLastFrame() { float tr = m_tLastTrip.Age(); return (tr>1.)?fSPS:(tr*fSPS); }
+ inline float GetSecondsSinceLastFrame() { float tr = m_tLastTrip.Age(); return (tr>1.f)?1.f:tr; }
+ inline unsigned int SamplesSinceLastFrame() { float tr = m_tLastTrip.Age(); return (unsigned int)(tr>1.)?fSPS:(tr*fSPS); }
//For registering and creation of new sound sources...
MAutoPtr< MercurySoundSource > LoadSoundSource( const MString & sSourceType, MAutoPtr< MercurySoundSource > Chain = 0 );
Modified: Mercury2/src/Win32Window.cpp
===================================================================
--- Mercury2/src/Win32Window.cpp 2010-04-25 19:42:25 UTC (rev 698)
+++ Mercury2/src/Win32Window.cpp 2010-04-25 20:16:49 UTC (rev 699)
@@ -2,7 +2,10 @@
//#include <Windowsx.h>
#include <GLHeaders.h>
#include <MercuryInput.h>
+#include <MercuryMessageManager.h>
+MVRefBool GlobalMouseGrabbed_Set( "Input.CursorGrabbed" );
+
LRESULT CALLBACK WindowCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); //Window callback
Callback0R< MercuryWindow* > MercuryWindow::genWindowClbk(Win32Window::GenWin32Window); //Register window generation callback
bool ACTIVE = false;
@@ -120,7 +123,11 @@
SetForegroundWindow(m_hwnd); // Slightly Higher Priority
SetFocus(m_hwnd); // Sets Keyboard Focus To The Window
-
+ //Resize windows so it's actually as big as we want, not minus borders.s
+ GetClientRect( m_hwnd, &rect );
+ int diffx = m_width - rect.right;
+ int diffy = m_height - rect.bottom;
+ SetWindowPos( m_hwnd, HWND_TOP, 0, 0, diffx + m_width, diffy + m_height, 0 );
}
void Win32Window::SetPixelType()
@@ -191,17 +198,29 @@
bool Win32Window::PumpMessages()
{
+ static int lastx, lasty;
+ static bool bWasCursorVisible;
MSG message;
if ( InFocus() != ACTIVE )
{
m_inFocus = ACTIVE;
ShowCursor(!m_inFocus);
- PointerToCenter();
+ if( GlobalMouseGrabbed_Set.Get() )
+ {
+ RECT rect;
+ GetWindowRect(m_hwnd, &rect);
+ SetCursorPos( rect.left + m_width/2, rect.top + m_height/2 );
+ }
}
while (PeekMessage(&message, NULL, 0, 0, PM_REMOVE))
{
+ RECT rect;
+ GetClientRect( m_hwnd, &rect );
+ m_width = rect.right;
+ m_height = rect.bottom;
+
if ( InFocus() )
{
switch( message.message )
@@ -221,33 +240,74 @@
case WM_MOUSEMOVE:
{
POINT pos;
+ RECT rect;
+ GetWindowRect(m_hwnd, &rect);
GetCursorPos(&pos);
- if (pos.x!=m_cX || pos.y!=m_cY) //ignore the resets to center
+ ScreenToClient(m_hwnd, &pos );
+ bool left = message.wParam&MK_LBUTTON;
+ bool right = message.wParam&MK_RBUTTON;
+ bool center = message.wParam&MK_MBUTTON;
+ bool su = 0;
+ bool sd = 0;
+ int px = pos.x;// - rect.left - borderx;
+ int py = pos.y;// - rect.top - bordery;
+
+ if( GlobalMouseGrabbed_Set.Get() )
{
- int dx = m_cX - pos.x;
- int dy = m_cY - pos.y;
- m_iLastMouseX += dx;
- m_iLastMouseY += dy;
- MouseInput::ProcessMouseInput(dx, dy, message.wParam&MK_LBUTTON, message.wParam&MK_RBUTTON, message.wParam&MK_MBUTTON, 0, 0);
- PointerToCenter();
+ int x, y;
+ x = m_width/2 - px;
+ y = m_height/2 - py;
+ if (x!=0 || y!=0) //prevent recursive XWarp
+ {
+ m_iLastMouseX = x;
+ m_iLastMouseY = y;
+ MouseInput::ProcessMouseInput(x, y, left, right, center, su, sd, true);
+ lastx = x; lasty = y;
+
+ pos.x = m_width/2;
+ pos.y = m_height/2;
+ ClientToScreen(m_hwnd, &pos );
+ SetCursorPos( pos.x, pos.y);
+ if( bWasCursorVisible )
+ {
+ bWasCursorVisible = false;
+ ShowCursor( false );
+ }
+ }
}
+ else
+ {
+ m_iLastMouseX = px;
+ m_iLastMouseY = py;
+ lastx = px; lasty = py;
+ MouseInput::ProcessMouseInput(px, py, left, right, center, su, sd, true);
+ if( !bWasCursorVisible )
+ {
+ ShowCursor( true );
+ bWasCursorVisible = true;
+ }
+ }
}
break;
case WM_LBUTTONDOWN:
- break;
case WM_LBUTTONUP:
- break;
case WM_RBUTTONDOWN:
- break;
case WM_RBUTTONUP:
- break;
case WM_MBUTTONDOWN:
- break;
case WM_MBUTTONUP:
+ MouseInput::ProcessMouseInput( lastx, lasty, message.wParam&MK_LBUTTON,
+ message.wParam&MK_RBUTTON, message.wParam&MK_MBUTTON, 0, 0, false);
break;
- case 0x020A: //Do nothing (at least now) It's a mouse wheel!
+ case 0x020A: //Not-too-well-documented mouse wheel.
+ {
+ short cx = short(message.wParam>>16);
+ MouseInput::ProcessMouseInput( lastx, lasty, message.wParam&MK_LBUTTON,
+ message.wParam&MK_RBUTTON, message.wParam&MK_MBUTTON, (cx>0), (cx<0), false);
+ MouseInput::ProcessMouseInput( lastx, lasty, message.wParam&MK_LBUTTON,
+ message.wParam&MK_RBUTTON, message.wParam&MK_MBUTTON, 0, 0, false);
break;
}
+ }
}
TranslateMessage(&message); // Translate The Message
DispatchMessage(&message); // Dispatch The Message
@@ -272,15 +332,6 @@
return (c&65535) > 1;
}
-void Win32Window::PointerToCenter()
-{
- RECT rect;
- GetWindowRect(m_hwnd, &rect);
- m_cX = rect.left+m_width/2;
- m_cY = rect.top+m_height/2;
- SetCursorPos(m_cX, m_cY);
-}
-
short Win32Window::ConvertScancode( uint32_t scanin )
{
// Specifies the scan code. The value depends on the OEM.
Modified: Mercury2/src/Win32Window.h
===================================================================
--- Mercury2/src/Win32Window.h 2010-04-25 19:42:25 UTC (rev 698)
+++ Mercury2/src/Win32Window.h 2010-04-25 20:16:49 UTC (rev 699)
@@ -28,8 +28,6 @@
void CreateRenderingContext();
void GenPixelType();
- void PointerToCenter();
-
HWND m_hwnd; //window handle
HDC m_hdc; //device handle
PIXELFORMATDESCRIPTOR m_pfd; //pixel format descriptor
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-04-25 19:42:31
|
Revision: 698
http://hgengine.svn.sourceforge.net/hgengine/?rev=698&view=rev
Author: axlecrusher
Date: 2010-04-25 19:42:25 +0000 (Sun, 25 Apr 2010)
Log Message:
-----------
use custom ABS macro
Modified Paths:
--------------
Mercury2/src/BoundingBox.cpp
Modified: Mercury2/src/BoundingBox.cpp
===================================================================
--- Mercury2/src/BoundingBox.cpp 2010-04-25 19:41:19 UTC (rev 697)
+++ Mercury2/src/BoundingBox.cpp 2010-04-25 19:42:25 UTC (rev 698)
@@ -149,7 +149,7 @@
if ( d.Length() > (ComputeRadius()+b.ComputeRadius()) ) return false; //quick circle check
MercuryVector l(m_extend+b.GetExtend());
- return l.GetX()<=abs(d.GetX()) && l.GetY()<=abs(d.GetY()) && l.GetZ()<=abs(d.GetZ());
+ return l.GetX()<=ABS(d.GetX()) && l.GetY()<=ABS(d.GetY()) && l.GetZ()<=ABS(d.GetZ());
}
bool BoundingBox::DoFrustumTest( const MercuryMatrix& m )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-04-25 19:41:25
|
Revision: 697
http://hgengine.svn.sourceforge.net/hgengine/?rev=697&view=rev
Author: axlecrusher
Date: 2010-04-25 19:41:19 +0000 (Sun, 25 Apr 2010)
Log Message:
-----------
Make FloatRow a class to abstract the differences between __m128 and float[4].
Clean up how numbers are accessed in MercuryVertex.
Modified Paths:
--------------
Mercury2/src/MercuryMath.cpp
Mercury2/src/MercuryMath.h
Mercury2/src/MercuryMatrix.cpp
Mercury2/src/MercuryVertex.cpp
Mercury2/src/MercuryVertex.h
Modified: Mercury2/src/MercuryMath.cpp
===================================================================
--- Mercury2/src/MercuryMath.cpp 2010-04-25 18:21:24 UTC (rev 696)
+++ Mercury2/src/MercuryMath.cpp 2010-04-25 19:41:19 UTC (rev 697)
@@ -144,6 +144,13 @@
f[i] = r[i];
}
+void MMCrossProduct( const FloatRow& r1, const FloatRow& r2, FloatRow& result)
+{
+ result[0] = r1[1]*r2[2] - r1[2]*r2[1];
+ result[1] = r1[2]*r2[0] - r1[0]*r2[2];
+ result[2] = r1[0]*r2[1] - r1[1]*r2[0];
+}
+
#else
//inline __m128 Hadd4(__m128 x);
@@ -258,7 +265,7 @@
void ZeroFloatRow(FloatRow& r)
{
- r = (FloatRow)_mm_setzero_ps();
+ r = _mm_setzero_ps();
}
void Float2FloatRow(const float* f, FloatRow& r)
@@ -271,6 +278,20 @@
_mm_store_ps( f, r );
}
+void MMCrossProduct( const FloatRow& r1, const FloatRow& r2, FloatRow& result)
+{
+ __m128 a,b,c,d,r;//using more registers is faster
+
+ a = _mm_shuffle_ps(r1, r1, 0xc9);
+ b = _mm_shuffle_ps(r2, r2, 0xd2);
+ r = _mm_mul_ps( a, b );
+
+ c = _mm_shuffle_ps(r2, r2, 0xc9);
+ d = _mm_shuffle_ps(r1, r1, 0xd2);
+ r -= _mm_mul_ps( c, d );
+ result = r;
+}
+
#endif
/*
Modified: Mercury2/src/MercuryMath.h
===================================================================
--- Mercury2/src/MercuryMath.h 2010-04-25 18:21:24 UTC (rev 696)
+++ Mercury2/src/MercuryMath.h 2010-04-25 19:41:19 UTC (rev 697)
@@ -10,10 +10,26 @@
#ifdef USE_SSE
#include <xmmintrin.h>
-typedef __m128 FloatRow __attribute__((aligned(16)));
+#endif
+class FloatRow
+{
+ public:
+ inline float& operator[](unsigned int i) { return ((float*)&m_floats)[i]; }
+ inline const float& operator[](unsigned int i) const { return ((const float*)&m_floats)[i]; }
+
+ inline operator float*() { return (float*)&m_floats; }
+ inline operator const float*() const { return (const float*)&m_floats; }
+
+#ifndef USE_SSE
+ float m_floats[4];
#else
-typedef float FloatRow[4];
+ inline FloatRow& operator=(const __m128& f) { m_floats=f; return *this; }
+
+ inline operator __m128&() { return m_floats; }
+ inline operator const __m128&() const { return m_floats; }
+ __m128 m_floats __attribute__((aligned(16)));
#endif
+};
#ifdef WIN32
#include <limits>
@@ -79,37 +95,15 @@
void MatrixMultiply4f ( const FloatRow* in1, const FloatRow* in2, FloatRow* out );
void VectorMultiply4f(const FloatRow* matrix, const FloatRow& p, FloatRow& out );
void TransposeMatrix( FloatRow* m );
+void MMCrossProduct( const FloatRow& r1, const FloatRow& r2, FloatRow& result);
//void Float2FloatRow(const float* f, FloatRow& r);
//void FloatRow2Float(const FloatRow& fr, float* f);
-#ifdef USE_SSE
-inline void MMCrossProduct( const FloatRow& r1, const FloatRow& r2, FloatRow& result)
-{
- __m128 a,b,c,d,r;//using more registers is faster
+const FloatRow gfrZero = { { 0.f, 0.f, 0.f, 0.f } };
- a = _mm_shuffle_ps(r1, r1, 0xc9);
- b = _mm_shuffle_ps(r2, r2, 0xd2);
- r = _mm_mul_ps( a, b );
-
- c = _mm_shuffle_ps(r2, r2, 0xc9);
- d = _mm_shuffle_ps(r1, r1, 0xd2);
- r -= _mm_mul_ps( c, d );
- result = r;
-}
-#else
-inline void MMCrossProduct( const FloatRow& r1, const FloatRow& r2, FloatRow& result)
-{
- result[0] = r1[1]*r2[2] - r1[2]*r2[1];
- result[1] = r1[2]*r2[0] - r1[0]*r2[2];
- result[2] = r1[0]*r2[1] - r1[1]*r2[0];
-}
#endif
-const FloatRow gfrZero = { 0.f, 0.f, 0.f, 0.f };
-
-#endif
-
/*
* (c) 2006 Joshua Allen
* All rights reserved.
Modified: Mercury2/src/MercuryMatrix.cpp
===================================================================
--- Mercury2/src/MercuryMatrix.cpp 2010-04-25 18:21:24 UTC (rev 696)
+++ Mercury2/src/MercuryMatrix.cpp 2010-04-25 19:41:19 UTC (rev 697)
@@ -8,7 +8,7 @@
0.0f, 0.0f, 0.0f, 1.0f };
MercuryMatrix::MercuryMatrix()
-{
+{/*
#ifdef USE_SSE
m_matrix[0] = _mm_load1_ps( &base_matrix_identity[0] );
m_matrix[1] = _mm_load1_ps( &base_matrix_identity[4] );
@@ -17,6 +17,8 @@
#else
Copy16f(m_matrix[0], base_matrix_identity );
#endif
+*/
+ *this = Identity();
}
const MercuryMatrix& MercuryMatrix::operator=(const MercuryMatrix& m)
@@ -46,7 +48,7 @@
if (!bSetIdentity)
{
bSetIdentity = true;
-#ifdef USE_SSE
+#ifdef USE_SSEXXX //XXX broken _mm_load1_ps routines
MercuryMatrix::IdentityMatrix.m_matrix[0] = _mm_load1_ps( &base_matrix_identity[0] );
MercuryMatrix::IdentityMatrix.m_matrix[1] = _mm_load1_ps( &base_matrix_identity[4] );
MercuryMatrix::IdentityMatrix.m_matrix[2] = _mm_load1_ps( &base_matrix_identity[8] );
Modified: Mercury2/src/MercuryVertex.cpp
===================================================================
--- Mercury2/src/MercuryVertex.cpp 2010-04-25 18:21:24 UTC (rev 696)
+++ Mercury2/src/MercuryVertex.cpp 2010-04-25 19:41:19 UTC (rev 697)
@@ -7,22 +7,22 @@
MercuryVertex::MercuryVertex()
{
- (*this)[0] = (*this)[1] = (*this)[2] = (*this)[3] = 0;
+ m_xyzw[0] = m_xyzw[1] = m_xyzw[2] = m_xyzw[3] = 0;
}
MercuryVertex::MercuryVertex( float ix, float iy, float iz, float iw )
{
- (*this)[0] = ix;
- (*this)[1] = iy;
- (*this)[2] = iz;
- (*this)[3] = iw;
+ m_xyzw[0] = ix;
+ m_xyzw[1] = iy;
+ m_xyzw[2] = iz;
+ m_xyzw[3] = iw;
}
MercuryVertex::MercuryVertex( const float* in3f, float f )
{
for (unsigned int i = 0; i < 3; ++i)
(*this)[i] = in3f[i];
- (*this)[3] = f;
+ m_xyzw[3] = f;
}
MercuryVertex::MercuryVertex( const float* in4f )
@@ -41,7 +41,7 @@
{
for (unsigned int i = 0; i < 3; ++i)
(*this)[i] = v[i];
- (*this)[3] = w;
+ m_xyzw[3] = w;
}
void MercuryVertex::NormalizeSelf()
@@ -60,19 +60,19 @@
float MercuryVertex::Length() const
{
- float length = (*this)[0]*(*this)[0];
- length += (*this)[1]*(*this)[1];
- length += (*this)[2]*(*this)[2];
- length += (*this)[3]*(*this)[3];
+ float length = m_xyzw[0]*m_xyzw[0];
+ length += m_xyzw[1]*m_xyzw[1];
+ length += m_xyzw[2]*m_xyzw[2];
+ length += m_xyzw[3]*m_xyzw[3];
return SQRT(length);
}
float MercuryVertex::GetBiggestElement() const
{
- float tmp = (*this)[0];
- tmp = MAX<float>(tmp, (*this)[1]);
- tmp = MAX<float>(tmp, (*this)[2]);
- return MAX<float>(tmp, (*this)[3]);
+ float tmp = m_xyzw[0];
+ tmp = MAX<float>(tmp, m_xyzw[1]);
+ tmp = MAX<float>(tmp, m_xyzw[2]);
+ return MAX<float>(tmp, m_xyzw[3]);
}
const MercuryVertex& MercuryVertex::operator *= (const MercuryVertex& p)
@@ -114,7 +114,7 @@
float MercuryVertex::DotProduct(const MercuryVertex& rhs) const
{
//XXX should this use all 4 components?
- return ((*this)[0]*rhs[0]+(*this)[1]*rhs[1]+(*this)[2]*rhs[2]);
+ return (m_xyzw[0]*rhs[0]+m_xyzw[1]*rhs[1]+m_xyzw[2]*rhs[2]);
}
MercuryVertex MercuryVertex::DotProduct3(const MercuryVertex& rhs1, const MercuryVertex& rhs2, const MercuryVertex& rhs3) const
@@ -150,7 +150,7 @@
MString MercuryVertex::Stringify(const MString& s) const
{
- return ssprintf("%s: %f %f %f %f", s.c_str(), (*this)[0], (*this)[1], (*this)[2], (*this)[3]);
+ return ssprintf("%s: %f %f %f %f", s.c_str(), m_xyzw[0], m_xyzw[1], m_xyzw[2], m_xyzw[3]);
}
MercuryVertex MercuryVertex::Rotate(const MQuaternion& q) const
Modified: Mercury2/src/MercuryVertex.h
===================================================================
--- Mercury2/src/MercuryVertex.h 2010-04-25 18:21:24 UTC (rev 696)
+++ Mercury2/src/MercuryVertex.h 2010-04-25 19:41:19 UTC (rev 697)
@@ -24,23 +24,23 @@
MercuryVertex( const MercuryVertex& v, float w);
///Direct conversion to float*
- __inline__ operator float* () { return (float*)&m_xyzw; }
+ __inline__ operator float* () { return m_xyzw; }
///Direct conversion to const float*
- __inline__ operator const float* () const { return (float*)&m_xyzw; }
+ __inline__ operator const float* () const { return m_xyzw; }
inline FloatRow& ToFloatRow() { return m_xyzw; }
inline const FloatRow& ToFloatRow() const { return m_xyzw; }
- inline float GetX() const { return (*this)[0]; }
- inline float GetY() const { return (*this)[1]; }
- inline float GetZ() const { return (*this)[2]; }
- inline float GetW() const { return (*this)[3]; }
- inline void SetX(const float ix) { (*this)[0] = ix; }
- inline void SetY(const float iy) { (*this)[1] = iy; }
- inline void SetZ(const float iz) { (*this)[2] = iz; }
- inline void SetW(const float iw) { (*this)[3] = iw; }
+ inline float GetX() const { return m_xyzw[0]; }
+ inline float GetY() const { return m_xyzw[1]; }
+ inline float GetZ() const { return m_xyzw[2]; }
+ inline float GetW() const { return m_xyzw[3]; }
+ inline void SetX(const float ix) { m_xyzw[0] = ix; }
+ inline void SetY(const float iy) { m_xyzw[1] = iy; }
+ inline void SetZ(const float iz) { m_xyzw[2] = iz; }
+ inline void SetW(const float iw) { m_xyzw[3] = iw; }
- inline void Zero() { (*this)[0] = 0; (*this)[1] = 0; (*this)[2] = 0; }
+ inline void Zero() { m_xyzw[0] = 0; m_xyzw[1] = 0; m_xyzw[2] = 0; }
///Normalize (make |point| = 1)
void NormalizeSelf();
@@ -52,11 +52,11 @@
float GetBiggestElement() const;
///Write out to be = to this point
- inline void ConvertToVector3( float* out ) const { out[0] = (*this)[0]; out[1] = (*this)[1]; out[2] = (*this)[2]; }
+ inline void ConvertToVector3( float* out ) const { out[0] = m_xyzw[0]; out[1] = m_xyzw[1]; out[2] = m_xyzw[2]; }
///Write out to be = to this point, however the 4th element will be 0
- inline void ConvertToVector4( float* out, float w = 0 ) const { out[0] = (*this)[0]; out[1] = (*this)[1]; out[2] = (*this)[2]; out[3] = w; }
+ inline void ConvertToVector4( float* out, float w = 0 ) const { out[0] = m_xyzw[0]; out[1] = m_xyzw[1]; out[2] = m_xyzw[2]; out[3] = w; }
///Write out to be = - to this point, however the 4th element will be 0
- inline void ConvertToIVector4( float* out, float w = 0 ) const { out[0] = -(*this)[0]; out[1] = -(*this)[1]; out[2] = -(*this)[2]; out[3] = w; }
+ inline void ConvertToIVector4( float* out, float w = 0 ) const { out[0] = -m_xyzw[0]; out[1] = -m_xyzw[1]; out[2] = -m_xyzw[2]; out[3] = w; }
const MercuryVertex& operator *= (const MercuryVertex& p);
const MercuryVertex& operator /= (const MercuryVertex& p);
@@ -66,15 +66,15 @@
MercuryVertex operator*(const MercuryMatrix& m) const;
- inline MercuryVertex& operator += ( const MercuryVertex& other ) { (*this)[0]+=other[0]; (*this)[1]+=other[1]; (*this)[2]+=other[2]; return *this; }
- inline MercuryVertex& operator -= ( const MercuryVertex& other ) { (*this)[0]-=other[0]; (*this)[1]-=other[1]; (*this)[2]-=other[2]; return *this; }
- inline MercuryVertex& operator *= ( float f ) { (*this)[0]*=f; (*this)[1]*=f; (*this)[2]*=f; return *this; }
- inline MercuryVertex& operator /= ( float f ) { (*this)[0]/=f; (*this)[1]/=f; (*this)[2]/=f; return *this; }
+ inline MercuryVertex& operator += ( const MercuryVertex& other ) { m_xyzw[0]+=other[0]; m_xyzw[1]+=other[1]; m_xyzw[2]+=other[2]; return *this; }
+ inline MercuryVertex& operator -= ( const MercuryVertex& other ) { m_xyzw[0]-=other[0]; m_xyzw[1]-=other[1]; m_xyzw[2]-=other[2]; return *this; }
+ inline MercuryVertex& operator *= ( float f ) { m_xyzw[0]*=f; m_xyzw[1]*=f; m_xyzw[2]*=f; return *this; }
+ inline MercuryVertex& operator /= ( float f ) { m_xyzw[0]/=f; m_xyzw[1]/=f; m_xyzw[2]/=f; return *this; }
- inline MercuryVertex operator + ( const MercuryVertex& other ) const { return MercuryVertex( (*this)[0]+other[0], (*this)[1]+other[1], (*this)[2]+other[2] ); }
- inline MercuryVertex operator - ( const MercuryVertex& other ) const { return MercuryVertex( (*this)[0]-other[0], (*this)[1]-other[1], (*this)[2]-other[2] ); }
- inline MercuryVertex operator * ( float f ) const { return MercuryVertex( (*this)[0]*f, (*this)[1]*f, (*this)[2]*f ); }
- inline MercuryVertex operator / ( float f ) const { return MercuryVertex( (*this)[0]/f, (*this)[1]/f, (*this)[2]/f ); }
+ inline MercuryVertex operator + ( const MercuryVertex& other ) const { return MercuryVertex( m_xyzw[0]+other[0], m_xyzw[1]+other[1], m_xyzw[2]+other[2] ); }
+ inline MercuryVertex operator - ( const MercuryVertex& other ) const { return MercuryVertex( m_xyzw[0]-other[0], m_xyzw[1]-other[1], m_xyzw[2]-other[2] ); }
+ inline MercuryVertex operator * ( float f ) const { return MercuryVertex( m_xyzw[0]*f, m_xyzw[1]*f, m_xyzw[2]*f ); }
+ inline MercuryVertex operator / ( float f ) const { return MercuryVertex( m_xyzw[0]/f, m_xyzw[1]/f, m_xyzw[2]/f ); }
bool operator==(const MercuryVertex& p) const;
inline bool operator!=(const MercuryVertex& p) const { return !(*this == p); }
@@ -96,7 +96,7 @@
static MercuryVertex CreateFromString(const MString& s);
-// float (*this)[3];
+// float m_xyzw[3];
FloatRow m_xyzw;
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-04-25 18:21:30
|
Revision: 696
http://hgengine.svn.sourceforge.net/hgengine/?rev=696&view=rev
Author: axlecrusher
Date: 2010-04-25 18:21:24 +0000 (Sun, 25 Apr 2010)
Log Message:
-----------
fix broken cnconfigure
Modified Paths:
--------------
Mercury2/cnconfigure
Modified: Mercury2/cnconfigure
===================================================================
--- Mercury2/cnconfigure 2010-04-25 17:59:43 UTC (rev 695)
+++ Mercury2/cnconfigure 2010-04-25 18:21:24 UTC (rev 696)
@@ -197,7 +197,7 @@
echo "">>Makefile
echo -e "all : \$(PROJ) library allmodules" >> Makefile
echo -e "\$(PROJ) : \$(OBJ)" >> Makefile
-echo -e "\t${cc} -o \$@ \$^ \$(LDFLAGS)" >> Makefile
+echo -e "\t${CC} -o \$@ \$^ \$(LDFLAGS)" >> Makefile
echo -e "help : " >> Makefile
echo -e " echo \"Available: <\$(PROJ)> <clean> <library> <help>\"" >> Makefile
if test `uname -s` == "Darwin" ; then
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-04-25 17:59:49
|
Revision: 695
http://hgengine.svn.sourceforge.net/hgengine/?rev=695&view=rev
Author: axlecrusher
Date: 2010-04-25 17:59:43 +0000 (Sun, 25 Apr 2010)
Log Message:
-----------
box intersection
Modified Paths:
--------------
Mercury2/src/BoundingBox.cpp
Mercury2/src/BoundingBox.h
Modified: Mercury2/src/BoundingBox.cpp
===================================================================
--- Mercury2/src/BoundingBox.cpp 2010-04-25 02:50:12 UTC (rev 694)
+++ Mercury2/src/BoundingBox.cpp 2010-04-25 17:59:43 UTC (rev 695)
@@ -109,12 +109,22 @@
*this = bb;
}
+float BoundingBox::ComputeRadius() const
+{
+/* MercuryVertex p(m_center+m_extend);
+ float r = (m_center-p).Length();
+ if (abs(m_extend.Length() - r) > .000001) printf("wrong %f %f\n",m_extend.Length(), r);
+ return (m_center-p).Length();
+ */
+ return m_extend.Length(); //this is actually correct, verified above
+}
+
bool BoundingBox::Clip( const MercuryPlane& p )
{
//do a quick spherical test using the signed distance
//from the center of the box
float d = p.GetNormal().DotProduct( m_center - p.GetCenter() );
- if (d < -m_extend.Length()) return true; //sphere is further than radius distance behind plane
+ if (d < -ComputeRadius()) return true; //sphere is further than radius distance behind plane
//all points must be behind a plane to be considered clipped
bool clip = true;
@@ -133,6 +143,15 @@
return clipped;
}
+bool BoundingBox::Intersect( const BoundingBox& b )
+{
+ MercuryVector d(m_center - b.m_center);
+ if ( d.Length() > (ComputeRadius()+b.ComputeRadius()) ) return false; //quick circle check
+
+ MercuryVector l(m_extend+b.GetExtend());
+ return l.GetX()<=abs(d.GetX()) && l.GetY()<=abs(d.GetY()) && l.GetZ()<=abs(d.GetZ());
+}
+
bool BoundingBox::DoFrustumTest( const MercuryMatrix& m )
{
BoundingBox bb(*this);
Modified: Mercury2/src/BoundingBox.h
===================================================================
--- Mercury2/src/BoundingBox.h 2010-04-25 02:50:12 UTC (rev 694)
+++ Mercury2/src/BoundingBox.h 2010-04-25 17:59:43 UTC (rev 695)
@@ -85,10 +85,13 @@
virtual bool Clip( const MercuryPlane& p );
virtual bool Clip( const Frustum& f );
+ virtual bool Intersect( const BoundingBox& b );
+
virtual bool DoFrustumTest( const MercuryMatrix& m );
virtual void DoOcclusionTest(OcclusionResult& result);
private:
+ float ComputeRadius() const;
void ComputeNormals();
static void PopulateVertices();
static void InitVBO();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2010-04-25 02:50:19
|
Revision: 694
http://hgengine.svn.sourceforge.net/hgengine/?rev=694&view=rev
Author: cnlohr
Date: 2010-04-25 02:50:12 +0000 (Sun, 25 Apr 2010)
Log Message:
-----------
commit dabbling with Wii... it may go somewhere...
Modified Paths:
--------------
Mercury2/base_set.sh
Mercury2/cnconfigure
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryCrash.c
Added Paths:
-----------
Mercury2/tools/wii_libs/
Mercury2/tools/wii_libs/Makefile
Mercury2/tools/wii_libs/Makefile.png
Mercury2/tools/wii_libs/Makefile.zlib
Modified: Mercury2/base_set.sh
===================================================================
--- Mercury2/base_set.sh 2010-04-22 00:01:37 UTC (rev 693)
+++ Mercury2/base_set.sh 2010-04-25 02:50:12 UTC (rev 694)
@@ -8,7 +8,7 @@
ISMAC=1; fi
-OPTIONS="X11 libxml OGL sse gprof glprofile instancewatch alsa ogg"
+OPTIONS="X11 libxml OGL sse gprof glprofile instancewatch alsa ogg wii"
OPT_X11=1
OPT_OGL=1
OPT_libxml=1
@@ -18,6 +18,7 @@
OPT_instancewatch=1
OPT_alsa=1
OPT_ogg=1
+OPT_wii=0
DEFINES="WAS_CONFIGURED USE_MSTRING"
@@ -52,9 +53,17 @@
WANT_L="iberty"
CC_BASE="$CC_BASE -I."
-NEED_L="m c z pthread png pthread";
+if test $OPT_wii = 1; then
+ CC="$DEVKITPPC/bin/powerpc-eabi-g++"
+ EXTRA_BEGIN="include $DEVKITPPC/wii_rules"
+ LD_BASE="$LD_BASE -g $MACHDEP -Ltools/wii_png -Wl,-Map,mercury.map $DEVKITPRO/libogc/lib/wii/libwiiuse.a $DEVKITPRO/libogc/lib/wii/libbte.a $DEVKITPRO/libogc/lib/wii/libogc.a"
+ NEED_L="m c png"
+ CC_BASE="$CC_BASE -I$DEVKITPRO/libogc/include"
+else
+ NEED_L="m c z pthread png pthread";
+ CC="cc"
+fi
-
if test $OPT_libxml = 1; then
CC_BASE="$CC_BASE -I/usr/include/libxml2"
NEED_H="$NEED_H libxml/parser.h"
@@ -110,10 +119,14 @@
ARCH=`uname -m`
-if test $ARCH = "i686" || test $ARCH = "i586"; then
- if test $OPT_sse = 1; then
- CC_BASE="$CC_BASE -march=pentium3"
- else
- CC_BASE="$CC_BASE -march=pentium"
+if test $OPT_wii = 1; then
+ CC_BASE="$CC_BASE -DGEKKO -mrvl -mcpu=750 -meabi -mhard-float"
+else
+ if test $ARCH = "i686" || test $ARCH = "i586"; then
+ if test $OPT_sse = 1; then
+ CC_BASE="$CC_BASE -march=pentium3"
+ else
+ CC_BASE="$CC_BASE -march=pentium"
+ fi
fi
fi
Modified: Mercury2/cnconfigure
===================================================================
--- Mercury2/cnconfigure 2010-04-22 00:01:37 UTC (rev 693)
+++ Mercury2/cnconfigure 2010-04-25 02:50:12 UTC (rev 694)
@@ -11,8 +11,8 @@
{
echo -n "Checking for <$1>... "
echo -e "#include <$1>\n" > tmp.c
-#echo gcc $CC_BASE -E tmp.c
-if gcc $CC_BASE -E tmp.c 1> foo 2> foo; then
+#echo ${CC} $CC_BASE -E tmp.c
+if $CC $CC_BASE -E tmp.c 1> foo 2> foo; then
# rm ./tmp.c
rm ./foo
echo "yes"
@@ -29,8 +29,8 @@
{
echo -n "Checking for -l$1... "
echo -e "int main() { return 0; }" > tmp.c
-#echo gcc $CC_BASE $LD_BASE -o bar tmp.c -l$1
-if gcc $CC_BASE $LD_BASE -o bar tmp.c -l$1 1> foo 2> foo; then
+#echo $CC $CC_BASE $LD_BASE -o bar tmp.c -l$1
+if $CC $CC_BASE $LD_BASE -o bar tmp.c -l$1 1> foo 2> foo; then
rm ./tmp.c
rm ./foo
rm ./bar
@@ -58,11 +58,11 @@
echo "#define $i" >> configuration.h
done
-echo "Compile line used: cc $CC_BASE"
+echo "Compile line used: $CC $CC_BASE"
echo -n "Checking to make sure standard cflags and compile are acceptable... "
echo -e "\n" > tmp.c
-if cc $CC_BASE -E tmp.c 1> foo 2> foo; then
+if $CC $CC_BASE -E tmp.c 1> foo 2> foo; then
rm ./foo
echo "yes"
else
@@ -71,10 +71,10 @@
exit -1
fi
-echo "Link line used: g++ $CC_BASE $LD_BASE"
+echo "Link line used: $CC $CC_BASE $LD_BASE"
echo -n "Checking to make sure ldflags and cflags are acceptable... "
echo -e "int main() { return 0; }" > tmp.c
-if g++ $CC_BASE $LD_BASE -o bar tmp.c 1> foo 2> foo; then
+if $CC $CC_BASE $LD_BASE -o bar tmp.c 1> foo 2> foo; then
rm ./tmp.c
rm ./foo
rm ./bar
@@ -128,7 +128,7 @@
return 0;
}\n" > tmp.c
-if gcc -o tmp.o tmp.c; then
+if cc -o tmp.o tmp.c; then
echo -n "Compile OK. "
rm ./tmp.c
else
@@ -170,6 +170,9 @@
echo "" > Makefile
+#if we need extra beginning parameters, tack them in here
+echo $EXTRA_BEGIN >> Makefile
+
echo -n "SOURCES=" >> Makefile
for i in $SOURCES; do
echo -n "$i " >> Makefile
@@ -184,16 +187,17 @@
LDFLAGS="$LDFLAGS $LD_BASE"
-echo "Final compile line: cc ${CC_BASE} ${CFLAGS} -c -o \$@ \$<"
+echo "Final compile line: ${CC} ${CC_BASE} ${CFLAGS} -c -o \$@ \$<"
echo "Final link line: g++ -o \$@ \$^ ${LDFLAGS}"
echo "PROJ=$PROJ" >> Makefile
+echo "CC=$CC" >> Makefile
echo "CFLAGS=$CC_BASE $CFLAGS" >> Makefile
echo "LDFLAGS=$LDFLAGS" >> Makefile
echo "">>Makefile
echo -e "all : \$(PROJ) library allmodules" >> Makefile
echo -e "\$(PROJ) : \$(OBJ)" >> Makefile
-echo -e "\tg++ -o \$@ \$^ \$(LDFLAGS)" >> Makefile
+echo -e "\t${cc} -o \$@ \$^ \$(LDFLAGS)" >> Makefile
echo -e "help : " >> Makefile
echo -e " echo \"Available: <\$(PROJ)> <clean> <library> <help>\"" >> Makefile
if test `uname -s` == "Darwin" ; then
@@ -208,7 +212,7 @@
echo "" >> Makefile
for i in $SOURCES; do
echo "Processing: $i"
- cc $CC_BASE $CFLAGS -MM "$i" -MT $( echo "$i" | sed "s/\.S/\.o/g;s/\.cpp/\.o/g;s/\.c/\.o/g" ) >> Makefile
+ ${CC} $CC_BASE $CFLAGS -MM "$i" -MT $( echo "$i" | sed "s/\.S/\.o/g;s/\.cpp/\.o/g;s/\.c/\.o/g" ) >> Makefile
#FIX THIS!!!! It should be don at make time, not here.
echo -e "\t\$(CC) \$(CC_BASE) \$(CFLAGS) -c -o \$@ \$<" >> Makefile
echo "" >> Makefile
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2010-04-22 00:01:37 UTC (rev 693)
+++ Mercury2/src/Mercury2.cpp 2010-04-25 02:50:12 UTC (rev 694)
@@ -15,7 +15,9 @@
#include <MercuryTimer.h>
#include <RenderGraph.h>
#include <Texture.h>
+#ifdef _HAVE_LIB_GL
#include <GLHeaders.h>
+#endif
#include <ModuleManager.h>
#include <MercuryFile.h>
@@ -200,8 +202,10 @@
//uncomment the next 2 lines to use threads
// UpdateLoopGo.Increment();
// updateThread.Wait();
-
+
+#ifdef _HAVE_LIB_GL
PrintGLFunctionCalls();
+#endif
SAFE_DELETE(root);
SAFE_DELETE(w);
Modified: Mercury2/src/MercuryCrash.c
===================================================================
--- Mercury2/src/MercuryCrash.c 2010-04-22 00:01:37 UTC (rev 693)
+++ Mercury2/src/MercuryCrash.c 2010-04-25 02:50:12 UTC (rev 694)
@@ -21,7 +21,7 @@
#ifndef __USE_POSIX
#define __USE_POSIX
#include <signal.h>
-#undef__USE_POSIX
+#undef __USE_POSIX
#else
#include <signal.h>
#endif
Added: Mercury2/tools/wii_libs/Makefile
===================================================================
--- Mercury2/tools/wii_libs/Makefile (rev 0)
+++ Mercury2/tools/wii_libs/Makefile 2010-04-25 02:50:12 UTC (rev 694)
@@ -0,0 +1,38 @@
+include $(DEVKITPPC)/wii_rules
+
+all : libpng.a libz.a
+
+PNG_TGZ:=libpng-1.4.1.tar.gz
+PNG_FOLDER:=libpng-1.4.1
+
+Z_TGZ:=zlib-1.2.4.tar.gz
+Z_FOLDER:=zlib-1.2.4
+
+$(PNG_TGZ) :
+ wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.4.1.tar.gz
+
+$(PNG_FOLDER) : $(PNG_TGZ)
+ tar xzvf $(PNG_TGZ)
+
+libpng.a : $(PNG_FOLDER) libz.a
+ (cd $(PNG_FOLDER)&&make -f../Makefile.png&&cd ..)
+ cp $(PNG_FOLDER)/libpng.a .
+
+$(Z_TGZ) :
+ wget http://zlib.net/zlib-1.2.4.tar.gz
+
+$(Z_FOLDER) : $(Z_TGZ)
+ tar xzvf $(Z_TGZ)
+
+libz.a : $(Z_FOLDER)
+ (cd $(Z_FOLDER)&&make -f../Makefile.zlib&&cd ..)
+ cp $(Z_FOLDER)/libz.a .
+
+clobber : clean
+ rm -rf $(PNG_TGZ) $(PNG_FOLDER) $(Z_TGZ) $(Z_FOLDER)
+
+clean :
+ rm -rf *~ libz.a libpng.a
+ (cd $(Z_FOLDER)&&make -f../Makefile.zlib clean&&cd ..)
+ (cd $(PNG_FOLDER)&&make -f../Makefile.png clean&&cd ..)
+
Added: Mercury2/tools/wii_libs/Makefile.png
===================================================================
--- Mercury2/tools/wii_libs/Makefile.png (rev 0)
+++ Mercury2/tools/wii_libs/Makefile.png 2010-04-25 02:50:12 UTC (rev 694)
@@ -0,0 +1,17 @@
+all : libpng.a minitest
+
+OBJS:=png.o pngerror.o pngget.o pngpread.o pngrio.o pngrtran.o pngrutil.o pngset.o pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o
+SRCS:=png.c pngerror.c pngget.c pngpread.c pngrio.c pngrtran.c pngrutil.c pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c
+
+libpng.a : $(OBJS)
+ $(DEVKITPPC)/bin/powerpc-eabi-ar rcs $@ $^
+
+%.o : %.c
+ $(DEVKITPPC)/bin/powerpc-eabi-gcc -I../zlib-1.2.4 -O2 -c -o $@ $^
+
+minitest : libpng.a
+ $(DEVKITPPC)/bin/powerpc-eabi-gcc -I../zlib-1.2.4 -O2 -c example.c -c -o example.o
+ $(DEVKITPPC)/bin/powerpc-eabi-gcc example.o -L. -L.. -lz -lpng
+
+clean :
+ rm -rf *~ *.o libz.a
Added: Mercury2/tools/wii_libs/Makefile.zlib
===================================================================
--- Mercury2/tools/wii_libs/Makefile.zlib (rev 0)
+++ Mercury2/tools/wii_libs/Makefile.zlib 2010-04-25 02:50:12 UTC (rev 694)
@@ -0,0 +1,17 @@
+all : libz.a minitest
+
+OBJS:=adler32.o crc32.o deflate.o gzclose.o gzlib.o gzread.o gzwrite.o infback.o inftrees.o inffast.o inflate.o trees.o uncompr.o zutil.o
+SRCS:=adler32.c crc32.c deflate.c gzclose.c gzlib.c gzread.c gzwrite.c infback.c inftrees.c inffast.c inflate.c trees.c uncompr.c zutil.c
+
+libz.a : $(OBJS)
+ $(DEVKITPPC)/bin/powerpc-eabi-ar rcs $@ $^
+
+%.o : %.c
+ $(DEVKITPPC)/bin/powerpc-eabi-gcc -O2 -c -o $@ $^
+
+minitest : libz.a
+ $(DEVKITPPC)/bin/powerpc-eabi-gcc -O2 -c minigzip.c -c -o minigzip.o
+ $(DEVKITPPC)/bin/powerpc-eabi-gcc minigzip.o -L. -lz
+
+clean :
+ rm -rf *~ *.o libz.a
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|