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: <cn...@us...> - 2010-06-02 04:49:29
|
Revision: 750
http://hgengine.svn.sourceforge.net/hgengine/?rev=750&view=rev
Author: cnlohr
Date: 2010-06-02 04:49:22 +0000 (Wed, 02 Jun 2010)
Log Message:
-----------
make Mercury compile under clang, still won't run
Modified Paths:
--------------
Mercury2/base_set.sh
Mercury2/src/MercuryLog.cpp
Mercury2/src/MercuryLog.h
Mercury2/src/MercurySoundDriverALSA.cpp
Mercury2/src/MercurySoundSourceVorbis.cpp
Mercury2/src/XMLParser.cpp
Modified: Mercury2/base_set.sh
===================================================================
--- Mercury2/base_set.sh 2010-05-23 15:56:37 UTC (rev 749)
+++ Mercury2/base_set.sh 2010-06-02 04:49:22 UTC (rev 750)
@@ -8,7 +8,7 @@
ISMAC=1; fi
-OPTIONS="X11 libxml OGL sse gprof glprofile instancewatch alsa ogg wii"
+OPTIONS="X11 libxml OGL sse gprof glprofile instancewatch alsa ogg wii clang"
OPT_X11=1
OPT_OGL=1
OPT_libxml=1
@@ -19,6 +19,7 @@
OPT_alsa=1
OPT_ogg=1
OPT_wii=0
+OPT_clang=0
DEFINES="WAS_CONFIGURED USE_MSTRING"
@@ -64,6 +65,10 @@
CC="cc"
fi
+if test $OPT_clang = 1; then
+ CC="clang"
+fi
+
if test $OPT_libxml = 1; then
CC_BASE="$CC_BASE -I/usr/include/libxml2"
NEED_H="$NEED_H libxml/parser.h"
Modified: Mercury2/src/MercuryLog.cpp
===================================================================
--- Mercury2/src/MercuryLog.cpp 2010-05-23 15:56:37 UTC (rev 749)
+++ Mercury2/src/MercuryLog.cpp 2010-06-02 04:49:22 UTC (rev 750)
@@ -7,7 +7,9 @@
void* MercuryLog::ThreadLoop(void* d)
{
+
MercuryLog* log = static_cast<MercuryLog*>(d);
+ log->Open( "log.txt" );
while (true)
{
@@ -15,6 +17,7 @@
log->WriteQueue();
msleep(100); //10x/sec
}
+ log->Close();
return 0;
}
@@ -34,12 +37,19 @@
void MercuryLog::Open(const MString& file)
{
- m_file.open(file.c_str());
+ if( m_file )
+ Close();
+
+ m_file = fopen( file.c_str(), "w" );
}
void MercuryLog::Close()
{
- m_file.close();
+ if( m_file )
+ {
+ fclose( m_file );
+ m_file = 0;
+ }
}
void MercuryLog::Write(const MString& message)
@@ -74,11 +84,11 @@
for (i = m_outQueue.begin(); i != m_outQueue.end(); ++i)
{
const MString& m = *i;
- cout << m << endl;
- m_file << m << endl;
+ fprintf( m_file, "%s\n", m.c_str() );
+ printf( "%s\n", m.c_str() );
}
- m_file.flush();
+ fflush( m_file );
m_outQueue.clear();
}
@@ -89,7 +99,6 @@
if (!pl)
{
pl = new MercuryProgramLog;
- pl->m_log.Open("log.txt");
}
return *pl;
}
Modified: Mercury2/src/MercuryLog.h
===================================================================
--- Mercury2/src/MercuryLog.h 2010-05-23 15:56:37 UTC (rev 749)
+++ Mercury2/src/MercuryLog.h 2010-06-02 04:49:22 UTC (rev 750)
@@ -1,7 +1,6 @@
#ifndef MERCURYLOG_H
#define MERCURYLOG_H
-#include <fstream>
#include <list>
#include <MercuryString.h>
#include <MercuryThreads.h>
@@ -26,10 +25,10 @@
void CopyQueue();
void WriteQueue();
+ FILE * m_file;
std::list< MString > m_queue;
std::list< MString > m_outQueue;
- std::ofstream m_file;
MercuryMutex m_mutex;
MercuryThread m_thread;
Modified: Mercury2/src/MercurySoundDriverALSA.cpp
===================================================================
--- Mercury2/src/MercurySoundDriverALSA.cpp 2010-05-23 15:56:37 UTC (rev 749)
+++ Mercury2/src/MercurySoundDriverALSA.cpp 2010-06-02 04:49:22 UTC (rev 750)
@@ -34,7 +34,7 @@
snd_pcm_sw_params_t *sw_params;
int err;
- MString sDevice = sParameters.length()?sParameters:"default";
+ MString sDevice = sParameters.length()?sParameters:MString("default");
unsigned int Samplerate = 44100;
int Channels = 2;
@@ -217,8 +217,8 @@
int MercurySoundDriverALSA::playback_function(int nrframes)
{
int err;
- short buf[nrframes*2];
- float ibuf[nrframes*2];
+ short *buf = new short[nrframes*2];
+ float *ibuf = new float[nrframes*2];
SOUNDMAN.FillBuffer( ibuf, nrframes );
@@ -236,6 +236,8 @@
SOUNDMAN.PostFill();
+ delete buf;
+ delete ibuf;
return err;
}
Modified: Mercury2/src/MercurySoundSourceVorbis.cpp
===================================================================
--- Mercury2/src/MercurySoundSourceVorbis.cpp 2010-05-23 15:56:37 UTC (rev 749)
+++ Mercury2/src/MercurySoundSourceVorbis.cpp 2010-06-02 04:49:22 UTC (rev 750)
@@ -188,7 +188,7 @@
unsigned long BF = BufferFree();
unsigned long BFL = BF;
- short tibuf[BF * 2];
+ short * tibuf = new short[BF * 2];
do
{
@@ -198,7 +198,10 @@
Vorbistotal_bytes_read += Vorbisbytes_read;
} while( Vorbisbytes_read > 0 && BFL );
if( Vorbisbytes_read < 0 )
+ {
+ delete tibuf;
return false;
+ }
for( unsigned i = 0; i < BF; i++ )
{
@@ -208,9 +211,15 @@
}
if( Vorbisbytes_read == 0 && PlayLeft() == 0 )
+ {
+ delete tibuf;
return false;
+ }
else
+ {
+ delete tibuf;
return true;
+ }
}
Modified: Mercury2/src/XMLParser.cpp
===================================================================
--- Mercury2/src/XMLParser.cpp 2010-05-23 15:56:37 UTC (rev 749)
+++ Mercury2/src/XMLParser.cpp 2010-06-02 04:49:22 UTC (rev 750)
@@ -125,8 +125,8 @@
MString path((const char*)d);
int pos = path.find(".");
- MString name = pos<=0?path:path.substr(0, pos);
- MString rpath = pos<=0?"":path.substr(pos+1); //skip the period
+ MString name = (pos<=0)?path:path.substr(0, pos);
+ MString rpath = (pos<=0)?MString():path.substr(pos+1); //skip the period
XMLNode parent = FindParentWithName( name );
if ( !parent.IsValid() )
@@ -167,8 +167,8 @@
if (path.length() > 0)
{
int pos = path.find(".");
- MString name = pos<=0?path:path.substr(0, pos);
- MString rpath = pos<=0?"":path.substr(pos+1); //skip the period
+ MString name = (pos<=0)?path:path.substr(0, pos);
+ MString rpath = (pos<=0)?MString():path.substr(pos+1); //skip the period
for (XMLNode n = this->Child(); n.IsValid(); n = n.NextNode())
if (n.Attribute("name") == name)
return n.RecursiveFindFallbackNode(rpath);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-23 15:56:43
|
Revision: 749
http://hgengine.svn.sourceforge.net/hgengine/?rev=749&view=rev
Author: axlecrusher
Date: 2010-05-23 15:56:37 +0000 (Sun, 23 May 2010)
Log Message:
-----------
fix windows compile VS2008
Modified Paths:
--------------
Mercury2/src/MercuryMath.cpp
Mercury2/src/MercuryNode.h
Mercury2/src/OGLExtensions.cpp
Mercury2/src/OGLExtensions.h
Modified: Mercury2/src/MercuryMath.cpp
===================================================================
--- Mercury2/src/MercuryMath.cpp 2010-05-23 15:56:04 UTC (rev 748)
+++ Mercury2/src/MercuryMath.cpp 2010-05-23 15:56:37 UTC (rev 749)
@@ -143,6 +143,13 @@
f[i] = r[i];
}
*/
+void LoadIdentity(FloatRow* matrix)
+{
+ float *m = (float*)matrix;
+ for (uint8_t i = 0; i < 16; ++i)
+ m[i] = i%5?0.0f:1.0f;
+}
+
void MMCrossProduct( const FloatRow& r1, const FloatRow& r2, FloatRow& result)
{
FloatRow r;
Modified: Mercury2/src/MercuryNode.h
===================================================================
--- Mercury2/src/MercuryNode.h 2010-05-23 15:56:04 UTC (rev 748)
+++ Mercury2/src/MercuryNode.h 2010-05-23 15:56:37 UTC (rev 749)
@@ -123,19 +123,19 @@
virtual void Render(const MercuryMatrix& matrix);
virtual void PostRender(const MercuryMatrix& matrix);
- virtual void SetHidden( bool bHide ) { m_flags = SetBit(m_flags,HIDDEN,bHide); } //is there anyway to make this not virtual??
+ virtual void SetHidden( bool bHide ) { m_flags = (uint8_t)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_flags = SetBit(m_flags,CULLED,t); }
+ inline void SetCulled(bool t) { m_flags = (uint8_t)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 void SetSaveChildren(bool t) { m_flags = (uint8_t)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 void SetEnableSave(bool t) { m_flags = (uint8_t)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 void SetUseAlphaPass(bool t) { m_flags = (uint8_t)SetBit(m_flags,ALPHAPATH,t); }
inline bool GetUseAlphaPass() const { return GetBit(m_flags,ALPHAPATH); }
virtual MercuryMatrix ManipulateMatrix(const MercuryMatrix& matrix);
Modified: Mercury2/src/OGLExtensions.cpp
===================================================================
--- Mercury2/src/OGLExtensions.cpp 2010-05-23 15:56:04 UTC (rev 748)
+++ Mercury2/src/OGLExtensions.cpp 2010-05-23 15:56:37 UTC (rev 749)
@@ -12,6 +12,7 @@
PFNGLGENBUFFERSARBPROC glGenBuffersARB;
PFNGLBUFFERDATAARBPROC glBufferDataARB;
+PFNGLBUFFERSUBDATAARBPROC glBufferSubDataARB;
PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements;
@@ -70,6 +71,7 @@
EXTENSION( PFNGLCLIENTACTIVETEXTUREARBPROC,glClientActiveTextureARB );
EXTENSION( PFNGLGENBUFFERSARBPROC,glGenBuffersARB );
EXTENSION( PFNGLBUFFERDATAARBPROC,glBufferDataARB );
+EXTENSION( PFNGLBUFFERSUBDATAARBPROC,glBufferSubDataARB );
EXTENSION( PFNGLDRAWRANGEELEMENTSPROC,glDrawRangeElements );
Modified: Mercury2/src/OGLExtensions.h
===================================================================
--- Mercury2/src/OGLExtensions.h 2010-05-23 15:56:04 UTC (rev 748)
+++ Mercury2/src/OGLExtensions.h 2010-05-23 15:56:37 UTC (rev 749)
@@ -8,6 +8,7 @@
extern PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB;
extern PFNGLGENBUFFERSARBPROC glGenBuffersARB;
extern PFNGLBUFFERDATAARBPROC glBufferDataARB;
+extern PFNGLBUFFERSUBDATAARBPROC glBufferSubDataARB;
extern PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements;
//glsl
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-23 15:56:11
|
Revision: 748
http://hgengine.svn.sourceforge.net/hgengine/?rev=748&view=rev
Author: axlecrusher
Date: 2010-05-23 15:56:04 +0000 (Sun, 23 May 2010)
Log Message:
-----------
Change asset creation to generate keys BEFORE asking for the asset
Modified Paths:
--------------
Mercury2/src/MercuryAsset.cpp
Mercury2/src/MercuryAsset.h
Mercury2/src/MercuryNode.cpp
Mercury2/src/Texture.cpp
Mercury2/src/Texture.h
Modified: Mercury2/src/MercuryAsset.cpp
===================================================================
--- Mercury2/src/MercuryAsset.cpp 2010-05-23 12:38:12 UTC (rev 747)
+++ Mercury2/src/MercuryAsset.cpp 2010-05-23 15:56:04 UTC (rev 748)
@@ -154,14 +154,14 @@
return *instance;
}
-bool AssetFactory::RegisterFactoryCallback(const MString & type, MAutoPtr< MercuryAsset > (*functor)( const MString &, bool ) )
+bool AssetFactory::RegisterFactoryCallback(const MString & type, MAutoPtr< MercuryAsset > (*functor)( const MString &, bool, const XMLNode* n ) )
{
MString t = ToUpper( type );
m_factoryCallbacks[t] = functor;
return true;
}
-MAutoPtr<MercuryAsset> AssetFactory::Generate(const MString& type, const MString& key, bool bInstanced )
+MAutoPtr<MercuryAsset> AssetFactory::Generate(const MString& type, const MString& key, bool bInstanced, const XMLNode* n )
{
MString t = ToUpper( type );
@@ -172,11 +172,11 @@
}
printf( "Asset (%s) not found, generating\n", (t+key).c_str() );
- MAutoPtr< MercuryAsset > (**generator)( const MString &, bool ) = m_factoryCallbacks.get( t );
+ MAutoPtr< MercuryAsset > (**generator)( const MString &, bool, const XMLNode* n ) = m_factoryCallbacks.get( t );
if( generator )
{
- MAutoPtr< MercuryAsset > g = (**generator)(key, bInstanced);
+ MAutoPtr< MercuryAsset > g = (**generator)(key, bInstanced, n);
AddAssetInstance( t+key, g.Ptr() );
g->slType = g->GetType();
return g;
Modified: Mercury2/src/MercuryAsset.h
===================================================================
--- Mercury2/src/MercuryAsset.h 2010-05-23 12:38:12 UTC (rev 747)
+++ Mercury2/src/MercuryAsset.h 2010-05-23 15:56:04 UTC (rev 748)
@@ -78,6 +78,7 @@
virtual MercuryAssetInstance * MakeAssetInstance( MercuryNode * ParentNode );
+ static MString GenKey(const MString& k, const XMLNode* n) { return k; }
GENRTTI( MercuryAsset );
const char * slType; //Tricky - we need to know our type in the destructor. Don't touch this.
@@ -145,9 +146,9 @@
{
public:
static AssetFactory& GetInstance();
- bool RegisterFactoryCallback(const MString& type, MAutoPtr< MercuryAsset > (*)( const MString &, bool ) );
+ bool RegisterFactoryCallback(const MString& type, MAutoPtr< MercuryAsset > (*)( const MString &, bool, const XMLNode* ) );
- MAutoPtr<MercuryAsset> Generate(const MString& type, const MString& key, bool bInstanced = true );
+ MAutoPtr<MercuryAsset> Generate(const MString& type, const MString& key, bool bInstanced = true, const XMLNode* n = NULL );
void AddAssetInstance(const MString& key, MercuryAsset* asset);
void RemoveAssetInstance(const MString& key);
@@ -155,7 +156,7 @@
private:
MAutoPtr< MercuryAsset > LocateAsset( const MString& key ) { MAutoPtr< MercuryAsset > * a = m_assetInstances.get( key ); return a?(*a):0; }
- MHash< MAutoPtr< MercuryAsset > (*)( const MString &, bool ) > m_factoryCallbacks;
+ MHash< MAutoPtr< MercuryAsset > (*)( const MString &, bool, const XMLNode* ) > m_factoryCallbacks;
//the actual storage point is in MercuryAssetInstance
MHash< MAutoPtr< MercuryAsset > > m_assetInstances;
@@ -167,7 +168,7 @@
static InstanceCounter<AssetFactory> AFcounter("AssetFactory");
#define REGISTER_ASSET_TYPE(class)\
- MAutoPtr<MercuryAsset> FactoryFunct##class( const MString & key, bool bInstanced ) { return new class( key, bInstanced ); } \
+ MAutoPtr<MercuryAsset> FactoryFunct##class( const MString & key, bool bInstanced, const XMLNode* n) { return new class( class::GenKey(key,n), bInstanced ); } \
bool GlobalRegisterSuccess##class = AssetFactory::GetInstance().RegisterFactoryCallback(#class, FactoryFunct##class);
#define CLASS_HELPERS(baseClass)\
Modified: Mercury2/src/MercuryNode.cpp
===================================================================
--- Mercury2/src/MercuryNode.cpp 2010-05-23 12:38:12 UTC (rev 747)
+++ Mercury2/src/MercuryNode.cpp 2010-05-23 15:56:04 UTC (rev 748)
@@ -306,7 +306,8 @@
else if ( child.Name() == "asset" )
{
MString key = child.Attribute("file");
- MAutoPtr< MercuryAsset > asset( AssetFactory::GetInstance().Generate( child.Attribute("type"), key ) );
+
+ MAutoPtr< MercuryAsset > asset( AssetFactory::GetInstance().Generate( child.Attribute("type"), key, true, &child ) );
if ( asset.IsValid() )
{
asset->LoadFromXML( child );
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2010-05-23 12:38:12 UTC (rev 747)
+++ Mercury2/src/Texture.cpp 2010-05-23 15:56:04 UTC (rev 748)
@@ -152,10 +152,10 @@
if( sNewKey == m_path && GetLoadState() != NONE )
return true;
- if ( m_dynamic )
- MakeDynamic( 0, 0, RGBA, sNewKey );
+ if ( !m_dynamic )
+ LoadImagePath( sNewKey );
else
- LoadImagePath( sNewKey );
+// MakeDynamic( 0, 0, RGBA, sNewKey );
if( sNewKey != m_path )
return MercuryAsset::ChangeKey( sNewKey );
@@ -320,6 +320,18 @@
LoadImagePath(m_path);
}
+MString Texture::GenKey(const MString& k, const XMLNode* n)
+{
+ bool dynamic = false;
+ if (n)
+ {
+ const XMLNode& node = *n;
+ LOAD_FROM_XML( "dynamic", dynamic, StrToBool );
+ }
+ if (dynamic) return "DYNATEXT"+k;
+ return k;
+}
+
MAutoPtr< Texture > Texture::LoadFromFile(const MString& path)
{
MAutoPtr< MercuryAsset > t( AssetFactory::GetInstance().Generate("Texture", path) );
Modified: Mercury2/src/Texture.h
===================================================================
--- Mercury2/src/Texture.h 2010-05-23 12:38:12 UTC (rev 747)
+++ Mercury2/src/Texture.h 2010-05-23 15:56:04 UTC (rev 748)
@@ -46,6 +46,8 @@
static void ApplyActiveTextures(uint16_t stride, uint8_t uvByteOffset);
static void DisableUnusedTextures();
+ static MString GenKey(const MString& k, const XMLNode* n);
+
void SetFilter( TextureFilterMode t ) { m_tFilterMode = t; }
GENRTTI( Texture );
protected:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-23 12:38:18
|
Revision: 747
http://hgengine.svn.sourceforge.net/hgengine/?rev=747&view=rev
Author: axlecrusher
Date: 2010-05-23 12:38:12 +0000 (Sun, 23 May 2010)
Log Message:
-----------
Move bind cache init into render
Modified Paths:
--------------
Mercury2/src/Texture.cpp
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2010-05-23 12:37:21 UTC (rev 746)
+++ Mercury2/src/Texture.cpp 2010-05-23 12:38:12 UTC (rev 747)
@@ -102,6 +102,8 @@
void Texture::Render(const MercuryNode* node)
{
+ if ( !m_lastBound ) InitiateBindCache();
+
if (GetLoadState() == LOADED)
{
printf( "Rendering Texture (%s), but state is: %d\n", m_path.c_str(), GetLoadState() );
@@ -109,6 +111,9 @@
SetLoadState(NONE);
//force rebind since we were used before
if (m_lastBound[m_numActiveTextures] == this) m_lastBound[m_numActiveTextures] = NULL;
+
+// for (uint8_t i = 0; i <= m_numActiveTextures; i++)
+// if (m_lastBound[i] == this) m_lastBound[i] = NULL;
}
BindTexture();
}
@@ -159,7 +164,7 @@
void Texture::BindTexture()
{
- if ( !m_lastBound ) InitiateBindCache();
+// if ( !m_lastBound ) InitiateBindCache();
if (m_numActiveTextures >= m_maxActiveTextures) return;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-23 12:37:27
|
Revision: 746
http://hgengine.svn.sourceforge.net/hgengine/?rev=746&view=rev
Author: axlecrusher
Date: 2010-05-23 12:37:21 +0000 (Sun, 23 May 2010)
Log Message:
-----------
try to minimize state changes
Modified Paths:
--------------
Mercury2/src/StateChanger.cpp
Modified: Mercury2/src/StateChanger.cpp
===================================================================
--- Mercury2/src/StateChanger.cpp 2010-05-22 19:13:36 UTC (rev 745)
+++ Mercury2/src/StateChanger.cpp 2010-05-23 12:37:21 UTC (rev 746)
@@ -106,18 +106,37 @@
{
if( bEnable )
{
- GLCALL( glEnable( GL_DEPTH_TEST ) );
+ if (m_lastState != ON)
+ {
+ GLCALL( glEnable( GL_DEPTH_TEST ) );
+ m_lastState = ON;
+ }
}
else
{
- GLCALL( glDisable( GL_DEPTH_TEST ) );
+ if (m_lastState != OFF)
+ {
+ GLCALL( glDisable( GL_DEPTH_TEST ) );
+ m_lastState = OFF;
+ }
}
}
STATECHANGE_RTTI( DepthTest );
- bool bEnable;
+
+ private:
+ bool bEnable;
+ enum LastDepthState
+ {
+ UNKNOWN,
+ ON,
+ OFF
+ };
+ static LastDepthState m_lastState;
};
+DepthTest::LastDepthState DepthTest::m_lastState = UNKNOWN;
+
REGISTER_STATECHANGE( DepthTest );
class DepthWrite : public StateChange
@@ -262,13 +281,24 @@
void Activate()
{
- GLCALL( glBlendFunc(m_src,m_dest) );
+ if ((m_src != m_lastSrc)||(m_dest!=m_lastDest))
+ {
+ GLCALL( glBlendFunc(m_src,m_dest) );
+ m_lastSrc = m_src;
+ m_lastDest = m_dest;
+ }
}
STATECHANGE_RTTI( BlendFunc );
- int m_src, m_dest;
+
+ private:
+ int m_src, m_dest;
+ static long m_lastSrc, m_lastDest;
};
+long BlendFunc::m_lastSrc = 0;
+long BlendFunc::m_lastDest = 0;
+
REGISTER_STATECHANGE( BlendFunc );
///Change the alpha blending function (can be useful for non-shader farcry-like foliage)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-22 19:13:42
|
Revision: 745
http://hgengine.svn.sourceforge.net/hgengine/?rev=745&view=rev
Author: axlecrusher
Date: 2010-05-22 19:13:36 +0000 (Sat, 22 May 2010)
Log Message:
-----------
we have to compute the particle's. its no longer updated every frame in the VBO
Modified Paths:
--------------
Mercury2/Themes/default/Graphic/FireParticles.vert
Modified: Mercury2/Themes/default/Graphic/FireParticles.vert
===================================================================
--- Mercury2/Themes/default/Graphic/FireParticles.vert 2010-05-22 19:12:07 UTC (rev 744)
+++ Mercury2/Themes/default/Graphic/FireParticles.vert 2010-05-22 19:13:36 UTC (rev 745)
@@ -6,6 +6,7 @@
uniform mat4 HG_ViewMatrix;
varying vec3 angleC;
varying vec4 particleData;
+uniform float EmitterTime;
mat4 glRotate(float angle, vec3 axis)
{
@@ -50,7 +51,8 @@
void main()
{
- particleData = gl_Color;
+ particleData = gl_Color;
+ particleData.x = EmitterTime-particleData.x;
vec4 pos = vec4(1.0);
pos.y = 0.3*(particleData.x*particleData.x) + 1.5*(particleData.x/particleData.y);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-22 19:12:13
|
Revision: 744
http://hgengine.svn.sourceforge.net/hgengine/?rev=744&view=rev
Author: axlecrusher
Date: 2010-05-22 19:12:07 +0000 (Sat, 22 May 2010)
Log Message:
-----------
Copy less data each render. A little faster.
Modified Paths:
--------------
Mercury2/modules/ParticleEmitter.cpp
Mercury2/modules/ParticleEmitter.h
Modified: Mercury2/modules/ParticleEmitter.cpp
===================================================================
--- Mercury2/modules/ParticleEmitter.cpp 2010-05-19 22:07:06 UTC (rev 743)
+++ Mercury2/modules/ParticleEmitter.cpp 2010-05-22 19:12:07 UTC (rev 744)
@@ -4,6 +4,7 @@
#include <MercuryVBO.h>
#include <Texture.h>
+#include <Shader.h>
#include <list>
using namespace std;
@@ -13,95 +14,71 @@
#define BUFFER_OFFSET(i) ((char*)NULL + (i))
ParticleBase::ParticleBase()
- :m_age(0), m_lifespan(0), m_particleVobData(NULL), m_particleIndexData(NULL)
+ :m_startTime(0), m_currentTime(0), m_lifespan(0), m_particleDynamicData(NULL), m_particleIndexData(NULL)
{
}
ParticleBase::~ParticleBase()
{
- m_particleVobData = NULL;
+ m_particleDynamicData = NULL;
m_particleIndexData = NULL;
}
-void ParticleBase::Init()
+void ParticleBase::Init(float time)
{
- m_age = 0;
+ //absolute time
+ m_startTime = m_currentTime = time;
}
-void ParticleBase::Update(float dTime)
+void ParticleBase::Update(float currentTime)
{
- m_age += dTime;
- WriteAgeToVBO();
-
- if (m_age >= m_lifespan) Deactivate();
+ m_currentTime = currentTime;
+ if ( !IsActive() ) Deactivate();
}
void ParticleBase::WriteAgeToVBO()
{
- m_emitter->SetDirtyVertices();
for (uint8_t i = 0; i < 4; ++i)
- WriteFloatToVertices(m_age,i,3);
+ WriteFloatToVertices(m_startTime,i,0);
}
void ParticleBase::WriteLifespanToVBO()
{
- m_emitter->SetDirtyVertices();
for (uint8_t i = 0; i < 4; ++i)
- WriteFloatToVertices(m_lifespan,i,4);
+ WriteFloatToVertices(m_lifespan,i,1);
}
void ParticleBase::WriteRand1ToVBO()
{
- m_emitter->SetDirtyVertices();
for (uint8_t i = 0; i < 4; ++i)
- WriteFloatToVertices(m_rand1,i,5);
+ WriteFloatToVertices(m_rand1,i,2);
}
void ParticleBase::WriteRand2ToVBO()
{
- m_emitter->SetDirtyVertices();
for (uint8_t i = 0; i < 4; ++i)
- WriteFloatToVertices(m_rand2,i,6);
+ WriteFloatToVertices(m_rand2,i,3);
}
void ParticleBase::Activate()
{
-// printf("Activate\n");
- uint8_t i = 0;
-
- //upper left
- m_particleVobData[i++] = -0.5; m_particleVobData[i++] = 0.5; m_particleVobData[i++] = 0;
- i+=4; m_particleVobData[i++] = 1; m_particleVobData[i++] = 0; //skip color data and set U,V
-
- //lower left
- m_particleVobData[i++] = -0.5; m_particleVobData[i++] = -0.5; m_particleVobData[i++] = 0;
- i+=4; m_particleVobData[i++] = 0; m_particleVobData[i++] = 0; //skip color data and set U,V
-
- //lower right
- m_particleVobData[i++] = 0.5; m_particleVobData[i++] = -0.5; m_particleVobData[i++] = 0;
- i+=4; m_particleVobData[i++] = 0; m_particleVobData[i++] = 1; //skip color data and set U,V
-
- //upper right
- m_particleVobData[i++] = 0.5; m_particleVobData[i++] = 0.5; m_particleVobData[i++] = 0;
- i+=4; m_particleVobData[i++] = 1; m_particleVobData[i++] = 1; //skip color data and set U,V
-
for (uint8_t i = 1; i < 4; ++i)
m_particleIndexData[i] = m_particleIndexData[0]+i; //reconstruct indices
-
- m_emitter->SetDirtyVertices();
- m_emitter->SetDirtyIndices();
+ m_emitter->SetIndexUpdateRange(m_particleIndexData,m_particleIndexData+4);
}
void ParticleBase::Deactivate()
{
for (uint8_t i = 1; i < 4; ++i)
m_particleIndexData[i] = m_particleIndexData[0]; //degenerate triangle renders nothing
- m_emitter->SetDirtyIndices();
+ m_emitter->SetIndexUpdateRange(m_particleIndexData,m_particleIndexData+4);
}
void ParticleBase::WriteFloatToVertices(float v, uint8_t vertexIndex, uint8_t offset)
{
- *(m_particleVobData+((STRIDE*vertexIndex)+offset)) = v;
+ unsigned long o = (4*vertexIndex)+offset;
+ *(m_particleDynamicData+o) = v;
+ m_emitter->SetDynamicUpdateRange(m_particleDynamicData+o,m_particleDynamicData+o+1);
}
void ParticleBase::WriteToVBO()
@@ -116,7 +93,9 @@
:base(), m_maxParticles(50), m_age(0), m_emitDelay(0.1f), m_lifespan(0),
m_particlesEmitted(0), m_particleMinLife(0.1f), m_particleMaxLife(5.0f),
m_particles(NULL), GenerateParticlesClbk(NULL),
- m_dirtyVBO(0)
+ m_fLastD(0),m_fLastI(0),
+ m_dBegin(0), m_dEnd(0),
+ m_iBegin(0), m_iEnd(0)
{
m_bufferID[0] = 0;
m_iForcePasses = m_iForcePasses | (1<<15);
@@ -127,9 +106,9 @@
ParticleEmitter::~ParticleEmitter()
{
- if (m_bufferID[0] > 0) { GLCALL( glDeleteBuffersARB(2, m_bufferID) ); }
+ if (m_bufferID[0] > 0) { GLCALL( glDeleteBuffersARB(3, m_bufferID) ); }
- SAFE_DELETE_ARRAY(m_particles); //do we need to destroy each element????
+ SAFE_DELETE_ARRAY(m_particles);
SAFE_DELETE(GenerateParticlesClbk);
}
@@ -137,29 +116,53 @@
void ParticleEmitter::Init()
{
MercuryNode::Init();
- SAFE_DELETE_ARRAY(m_particles); //do we need to destroy each element????
+ SAFE_DELETE_ARRAY(m_particles);
SetMaxParticleCount(m_maxParticles);
}
+void ParticleEmitter::InitGeometry(float* g)
+{
+ uint8_t i = 0;
+
+ //upper left
+ g[i++] = -0.5; g[i++] = 0.5; g[i++] = 0;
+ g[i++] = 1; g[i++] = 0; //U,V
+
+ //lower left
+ g[i++] = -0.5; g[i++] = -0.5; g[i++] = 0;
+ g[i++] = 0; g[i++] = 0; //U,V
+
+ //lower right
+ g[i++] = 0.5; g[i++] = -0.5; g[i++] = 0;
+ g[i++] = 0; g[i++] = 1; //U,V
+
+ //upper right
+ g[i++] = 0.5; g[i++] = 0.5; g[i++] = 0;
+ g[i++] = 1; g[i++] = 1; //U,V
+}
+
void ParticleEmitter::Update(float dTime)
{
m_age += dTime;
+ ++m_fLastD;
+ ++m_fLastI;
+
/* create particles until we meet the total number of
particles possible in terms of the age of the emitter */
while (((m_age-(m_particlesEmitted*m_emitDelay)) > m_emitDelay) && (m_emitDelay>0))
{
// LOG.Write("Emit");
++m_particlesEmitted; //always increment even if the maximum number of particles exist
- ActivateParticle();
+ ActivateParticle(m_age);
}
list< ParticleBase* >::iterator i = m_active.begin();
while ( i!=m_active.end() )
{
ParticleBase *p = *i;
- p->Update(dTime);
+ p->Update(m_age);
if ( !p->IsActive() )
{
m_active.erase(i++); //don't invalidate iterator before incrementing it
@@ -172,30 +175,24 @@
}
}
-void ParticleEmitter::ActivateParticle()
+void ParticleEmitter::ActivateParticle(float genTime)
{
if (!m_inactive.empty())
{
ParticleBase* p = m_inactive.front();
m_inactive.pop_front();
- p->Init();
+ p->Init(genTime);
p->Activate();
p->m_lifespan = m_particleMinLife;
p->m_lifespan += (rand()%(int(m_particleMaxLife*1000) - int(m_particleMinLife*1000)))/1000.0f;
p->m_rand1 = float(rand()%100000);
p->m_rand2 = float(rand()%100000);
-// +((rand()%((m_particleMaxLife*1000)-(m_particleMinLife*1000)))/1000.0f);
+ p->WriteToVBO();
- p->WriteAgeToVBO();
- p->WriteLifespanToVBO();
- p->WriteRand1ToVBO();
- p->WriteRand2ToVBO();
-
//add to the active list
-// printf("push %p\n", p);
m_active.push_back(p);
}
}
@@ -216,14 +213,15 @@
void ParticleEmitter::SetMaxParticleCount(uint16_t count)
{
- //3 floats for position
- //1 age, 1 lifespan, 2 random
- //7 floats total per particle
+ m_maxParticles = count;
- m_maxParticles = count;
- m_vertexData.Allocate(m_maxParticles*ParticleBase::STRIDE*4);
+ m_vertexDynamicData.Allocate(m_maxParticles*4*4);
+ m_geometryData.Allocate(m_maxParticles*4*5);
m_indexData.Allocate(m_maxParticles*4);
+ for (uint16_t i = 0; i < m_maxParticles*4*5; i+=(5*4))
+ InitGeometry(m_geometryData.Buffer()+i);
+
SAFE_DELETE_ARRAY(m_particles);
// if (GenerateParticlesClbk) m_particles = (*GenerateParticlesClbk)(m_maxParticles);
m_particles = new ParticleBase[m_maxParticles];
@@ -237,7 +235,7 @@
{
ParticleBase* p = m_particles+i;
p->m_emitter = this;
- p->m_particleVobData = m_vertexData.Buffer()+(ParticleBase::STRIDE*4*i);
+ p->m_particleDynamicData = m_vertexDynamicData.Buffer()+(4*4*i);
p->m_particleIndexData = m_indexData.Buffer() + (4*i);
p->m_particleIndexData[0]=p->m_particleIndexData[1]=p->m_particleIndexData[2]=p->m_particleIndexData[3]=i*4; //initial degenerate
p->Deactivate();
@@ -252,45 +250,80 @@
SetCulled(false);
}
+void ParticleEmitter::UpdateVBO()
+{
+ if ( ( m_iBegin > 0 ) || ( m_dBegin > 0 ))
+ {
+// LOG.Write( ssprintf("%d %d",m_fLastD,m_fLastI) );
+// LOG.Write( ssprintf("%p %p, %p %p, %d %d\n", m_dBegin, m_dEnd, m_iBegin, m_iEnd, (unsigned long)m_dEnd-(unsigned long)m_dBegin, (unsigned long)m_iEnd-(unsigned long)m_iBegin) );
+ }
+
+ if ( m_dBegin > 0 )
+ {
+ unsigned long l = (unsigned long)m_dEnd-(unsigned long)m_dBegin;
+ unsigned long s = (unsigned long)m_dBegin - (unsigned long)m_vertexDynamicData.Buffer();
+ GLCALL( glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_vertexDynamicData.LengthInBytes(), NULL, GL_DYNAMIC_DRAW_ARB) );
+ GLCALL( glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, s, l, m_dBegin));
+ m_fLastD = 0;
+ }
+ if ( m_iBegin > 0 )
+ {
+ unsigned long l = (unsigned long)m_iEnd-(unsigned long)m_iBegin;
+ unsigned long s = (unsigned long)m_iBegin - (unsigned long)m_indexData.Buffer();
+ GLCALL( glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_vertexDynamicData.LengthInBytes(), NULL, GL_DYNAMIC_DRAW_ARB) );
+ GLCALL( glBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, s, l, m_iBegin));
+ m_fLastI = 0;
+ }
+
+ m_dBegin = m_dEnd = m_iBegin = m_iEnd = 0;
+}
+
void ParticleEmitter::Render(const MercuryMatrix& matrix)
{
+ ShaderAttribute sa;
+ sa.type = ShaderAttribute::TYPE_FLOAT;
+ sa.value.fFloat = m_age;
+ Shader::SetAttribute("EmitterTime", sa);
+
GLCALL( glPushAttrib(GL_ENABLE_BIT|GL_CURRENT_BIT) );
GLCALL( glDisable(GL_CULL_FACE) );
if (m_bufferID[0]==0)
{
- GLCALL( glGenBuffersARB(2, m_bufferID) );
+ GLCALL( glGenBuffersARB(3, m_bufferID) );
+
+ GLCALL( glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferID[0]) ); //geometry VBO
+ GLCALL( glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_geometryData.LengthInBytes(), m_geometryData.Buffer(), GL_STATIC_DRAW_ARB) );
+
+ GLCALL( glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferID[1]) ); //dynamic data (age and randoms)
+ GLCALL( glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_vertexDynamicData.LengthInBytes(), m_vertexDynamicData.Buffer(), GL_DYNAMIC_DRAW_ARB) );
+
+ GLCALL( glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_bufferID[2]) );
+ GLCALL( glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_indexData.LengthInBytes(), m_indexData.Buffer(), GL_DYNAMIC_DRAW_ARB) );
+
+ m_dBegin = m_dEnd = m_iBegin = m_iEnd = 0;
}
- GLCALL( glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferID[0]) );
- GLCALL( glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_bufferID[1]) );
-// GLCALL( glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0) );
-
MercuryVBO::SetLastRendered(this);
- if (m_dirtyVBO&&0x1)
- {
- GLCALL( glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_vertexData.LengthInBytes(), m_vertexData.Buffer(), GL_STREAM_DRAW_ARB) );
- }
- if (m_dirtyVBO&&0x2)
- {
- GLCALL( glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_indexData.LengthInBytes(), m_indexData.Buffer(), GL_STREAM_DRAW_ARB) );
- }
- m_dirtyVBO = 0;
+ GLCALL( glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferID[0]) ); //geometry VBO contains XYZUV
+ Texture::ApplyActiveTextures(5*sizeof(float), 3*sizeof(float));
+ GLCALL( glEnableClientState(GL_VERTEX_ARRAY) );
+ GLCALL( glVertexPointer(3, GL_FLOAT, 5*sizeof(float), BUFFER_OFFSET( 0*sizeof(float) ) ) );
+
+ GLCALL( glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferID[1]) ); //dynamic data (age and randoms)
+ GLCALL( glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_bufferID[2]) );
+
+ UpdateVBO();
+
GLCALL( glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT) );
//do render stuff here
- Texture::ApplyActiveTextures(ParticleBase::STRIDE*sizeof(float), 7*sizeof(float));
- GLCALL( glEnableClientState(GL_VERTEX_ARRAY) );
GLCALL( glEnableClientState( GL_COLOR_ARRAY ) ); //used for attributes
-// GLCALL( glDisableClientState( GL_NORMAL_ARRAY ) );
- GLCALL( glVertexPointer(3, GL_FLOAT, ParticleBase::STRIDE*sizeof(float), BUFFER_OFFSET( 0*sizeof(float) ) ) );
- GLCALL( glColorPointer(4, GL_FLOAT, ParticleBase::STRIDE*sizeof(float), BUFFER_OFFSET( 3*sizeof(float) ) ) );
+ GLCALL( glColorPointer(4, GL_FLOAT, 4*sizeof(float), BUFFER_OFFSET( 0*sizeof(float) ) ) );
-// GLCALL( glDrawArrays(GL_QUADS, 0, m_maxParticles*4) );
-// GLCALL( glDrawRangeElements( GL_QUADS, 0, m_maxParticles*4,m_maxParticles*4, GL_UNSIGNED_SHORT, NULL) );
GLCALL( glDrawElements(GL_QUADS,m_maxParticles*4,GL_UNSIGNED_SHORT,0) );
GLCALL( glPopClientAttrib() );
@@ -302,6 +335,24 @@
base::Render(matrix);
}
+void ParticleEmitter::SetDynamicUpdateRange(void* begin, void* end)
+{
+ m_dBegin = m_dBegin==0?begin:m_dBegin;
+ m_dEnd = m_dEnd==0?end:m_dEnd;
+
+ m_dBegin = begin<m_dBegin?begin:m_dBegin;
+ m_dEnd = end>m_dEnd?end:m_dEnd;
+}
+
+void ParticleEmitter::SetIndexUpdateRange(void* begin, void* end)
+{
+ m_iBegin = m_iBegin==0?begin:m_iBegin;
+ m_iEnd = m_iEnd==0?end:m_iEnd;
+
+ m_iBegin = begin<m_iBegin?begin:m_iBegin;
+ m_iEnd = end>m_iEnd?end:m_iEnd;
+}
+
uint32_t ParticleEmitter::ResetDrawnCount()
{
uint32_t t = m_particlesDrawn;
@@ -309,6 +360,7 @@
return t;
}
+
uint32_t ParticleEmitter::m_particlesDrawn = 0;
/****************************************************************************
Modified: Mercury2/modules/ParticleEmitter.h
===================================================================
--- Mercury2/modules/ParticleEmitter.h 2010-05-19 22:07:06 UTC (rev 743)
+++ Mercury2/modules/ParticleEmitter.h 2010-05-22 19:12:07 UTC (rev 744)
@@ -12,23 +12,16 @@
ParticleBase();
~ParticleBase();
- virtual void Init();
virtual void Update(float dTime);
-// virtual void RecursiveRender();
-
void Activate();
void Deactivate();
void WriteToVBO();
+
+ void Init(float time);
- inline bool IsActive() const { return m_age < m_lifespan; }
-
-// GENRTTI( ParticleBase );
+ inline bool IsActive() const { return m_currentTime < m_lifespan+m_startTime; }
private:
-// CLASS_HELPERS( MercuryNode );
-
- static const uint8_t STRIDE = 9;
-
void WriteAgeToVBO();
void WriteLifespanToVBO();
void WriteRand1ToVBO();
@@ -36,13 +29,11 @@
void WriteFloatToVertices(float v, uint8_t vertexIndex, uint8_t offset);
friend class ParticleEmitter;
-// ParticleBase *m_prev, *m_next;
- float m_age;
+ float m_startTime,m_currentTime;
float m_lifespan;
float m_rand1, m_rand2;
ParticleEmitter* m_emitter;
-// MercuryNode* m_particleGraph;
- float* m_particleVobData; //pointer to position in VBO
+ float* m_particleDynamicData; //pointer to position in VBO
uint16_t* m_particleIndexData; //pointer to position in index list
};
@@ -64,19 +55,17 @@
void SetMaxParticleCount(uint16_t count);
- inline void SetDirtyVertices() { m_dirtyVBO = m_dirtyVBO||0x1; }
- inline void SetDirtyIndices() { m_dirtyVBO = m_dirtyVBO||0x2; }
+ void SetDynamicUpdateRange(void* begin, void* end);
+ void SetIndexUpdateRange(void* begin, void* end);
static uint32_t ResetDrawnCount();
GENRTTI( ParticleEmitter );
private:
-// void DestroyParticles();
- void ActivateParticle();
+ void ActivateParticle(float genTime);
+ void InitGeometry(float* g);
+ void UpdateVBO();
-// void FillUnusedParticleList(ParticleBase* p, uint32_t i);
-// void InitNewParticles(ParticleBase* p, uint32_t i, uint16_t vobStep, float* vob);
-
CLASS_HELPERS( MercuryNode );
uint32_t m_maxParticles;
@@ -89,15 +78,17 @@
ParticleBase *m_particles;
Callback1R<uint32_t,ParticleBase*>* GenerateParticlesClbk;
- AlignedBuffer<float> m_vertexData;
+ AlignedBuffer<float> m_geometryData; //xyzuv, stride 5
+ AlignedBuffer<float> m_vertexDynamicData; //1 age, 1 lifespan, 2 random, stide 4
AlignedBuffer<uint16_t> m_indexData;
- unsigned int m_bufferID[2];
-// bool m_dirtyVBO;
- uint8_t m_dirtyVBO;
+ unsigned int m_bufferID[3];
+ unsigned int m_fLastD;
+ unsigned int m_fLastI;
+ void *m_dBegin, *m_dEnd; //pointers to area of the m_vertexDynamicData that changed
+ void *m_iBegin, *m_iEnd; //pointers to area of the m_indexData that changed
std::list< ParticleBase* > m_active, m_inactive;
-// MercuryNode* m_masterParticle;
static uint32_t m_particlesDrawn;
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-19 22:07:12
|
Revision: 743
http://hgengine.svn.sourceforge.net/hgengine/?rev=743&view=rev
Author: axlecrusher
Date: 2010-05-19 22:07:06 +0000 (Wed, 19 May 2010)
Log Message:
-----------
fix bug that keeps textures from rendering
Modified Paths:
--------------
Mercury2/src/Texture.cpp
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2010-05-19 22:05:52 UTC (rev 742)
+++ Mercury2/src/Texture.cpp 2010-05-19 22:07:06 UTC (rev 743)
@@ -104,9 +104,11 @@
{
if (GetLoadState() == LOADED)
{
- printf( "Rendering Texture (%s), but state is: %d\n", m_path.c_str(), GetLoadState() );
+ printf( "Rendering Texture (%s), but state is: %d\n", m_path.c_str(), GetLoadState() );
LoadFromRaw();
SetLoadState(NONE);
+ //force rebind since we were used before
+ if (m_lastBound[m_numActiveTextures] == this) m_lastBound[m_numActiveTextures] = NULL;
}
BindTexture();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-19 22:05:58
|
Revision: 742
http://hgengine.svn.sourceforge.net/hgengine/?rev=742&view=rev
Author: axlecrusher
Date: 2010-05-19 22:05:52 +0000 (Wed, 19 May 2010)
Log Message:
-----------
Clean setting and using matrix pointers. This causes a large speedup of all matrix math operations. I suspect this is much friendlier to the CPU cache.
Modified Paths:
--------------
Mercury2/src/Camera.cpp
Mercury2/src/Light.cpp
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryNode.cpp
Mercury2/src/MercuryNode.h
Mercury2/src/RenderGraph.cpp
Mercury2/src/TransformNode.cpp
Mercury2/src/TransformNode.h
Modified: Mercury2/src/Camera.cpp
===================================================================
--- Mercury2/src/Camera.cpp 2010-05-19 16:42:33 UTC (rev 741)
+++ Mercury2/src/Camera.cpp 2010-05-19 22:05:52 UTC (rev 742)
@@ -45,7 +45,7 @@
{
m_tainted = false;
- MercuryMatrix local, parent(GetParentMatrix());
+ MercuryMatrix local, parent(*m_pGlobalMatrix);
MQuaternion r( GetRotation() );
Modified: Mercury2/src/Light.cpp
===================================================================
--- Mercury2/src/Light.cpp 2010-05-19 16:42:33 UTC (rev 741)
+++ Mercury2/src/Light.cpp 2010-05-19 22:05:52 UTC (rev 742)
@@ -30,8 +30,8 @@
void Light::Render(const MercuryMatrix& matrix)
{
- m_worldPosition = FindModelViewMatrix();
- m_worldPosition2 = FindGlobalMatrix();
+ m_worldPosition = GetModelViewMatrix();
+ m_worldPosition2 = GetGlobalMatrix();
CURRENTRENDERGRAPH->AddDifferedLight( this );
// m_boundingVolume->Render();
// m_parent = node;
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2010-05-19 16:42:33 UTC (rev 741)
+++ Mercury2/src/Mercury2.cpp 2010-05-19 22:05:52 UTC (rev 742)
@@ -35,7 +35,7 @@
bool SHOWBOUNDINGVOLUME = false;
bool SHOWAXISES = false;
bool DOOCCLUSIONCULL = false;
-
+/*
MSemaphore UpdateLoopGo;
void* UpdateThread(void* node)
{
@@ -46,7 +46,7 @@
}
return NULL;
}
-
+*/
int SignalHandler( int signal )
{
char buffer[2048];
@@ -144,9 +144,12 @@
do
{
timer.Touch();
+
+ root->RecursiveUpdate( timer.Age(), MercuryMatrix::IdentityMatrix ); //comment to use threads
+
+ //seems to work better after update. is this the correct place?
MESSAGEMAN.PumpMessages( timer.MicrosecondsSinceInit() );
- root->RecursiveUpdate( timer.Age() ); //comment to use threads
CURRENTRENDERGRAPH = &renderGraph;
if ( MercuryNode::NeedsRebuild() )
Modified: Mercury2/src/MercuryNode.cpp
===================================================================
--- Mercury2/src/MercuryNode.cpp 2010-05-19 16:42:33 UTC (rev 741)
+++ Mercury2/src/MercuryNode.cpp 2010-05-19 22:05:52 UTC (rev 742)
@@ -20,8 +20,8 @@
m_nextSibling(NULL), m_flags(SAVECHILDREN & ENABLESAVE),
m_iPasses( DEFAULT_PASSES ), m_iForcePasses( 0 )
{
- m_pGlobalMatrix = &MercuryMatrix::Identity();
- m_pModelViewMatrix = &MercuryMatrix::Identity();
+ m_pGlobalMatrix = &MercuryMatrix::IdentityMatrix;
+ m_pModelViewMatrix = &MercuryMatrix::IdentityMatrix;
}
MercuryNode::~MercuryNode()
@@ -192,12 +192,15 @@
return 0;
}
-void MercuryNode::RecursiveUpdate(float dTime)
+void MercuryNode::RecursiveUpdate(float dTime, const MercuryMatrix& globalMatrix)
{
+ m_pGlobalMatrix = &globalMatrix;
+ if (m_parent) m_pModelViewMatrix = m_parent->m_pModelViewMatrix;
+
Update(dTime);
-
+
for (MercuryNode* child = FirstChild(); child != NULL; child = NextChild(child))
- child->RecursiveUpdate(dTime);
+ child->RecursiveUpdate(dTime, *m_pGlobalMatrix);
}
void MercuryNode::RecursivePreRender()
@@ -421,40 +424,11 @@
(*i)->Asset().PostRender(this);
}
-const MercuryMatrix& MercuryNode::FindGlobalMatrix() const
-{
- const MercuryNode* n = NULL;
- const TransformNode* tn;
- for (n = this; n; n = n->Parent())
- {
- tn = TransformNode::Cast(n);
- if ( tn )
- return tn->GetGlobalMatrix();
- }
-
- return MercuryMatrix::Identity();
-}
-
-const MercuryMatrix& MercuryNode::FindModelViewMatrix() const
-{
- const MercuryNode* n = NULL;
- const TransformNode* tn;
- for (n = this; n; n = n->Parent())
- {
- tn = TransformNode::Cast(n);
- if ( tn )
- return tn->GetModelViewMatrix();
- }
-
- return MercuryMatrix::Identity();
-}
-
MercuryMatrix MercuryNode::ManipulateMatrix(const MercuryMatrix& matrix)
{
return VIEWMATRIX * matrix;
}
-
NodeFactory& NodeFactory::GetInstance()
{
static NodeFactory* instance = NULL;
Modified: Mercury2/src/MercuryNode.h
===================================================================
--- Mercury2/src/MercuryNode.h 2010-05-19 16:42:33 UTC (rev 741)
+++ Mercury2/src/MercuryNode.h 2010-05-19 22:05:52 UTC (rev 742)
@@ -71,7 +71,7 @@
MercuryNode * TraversalNextNode( MercuryNode * stopnode, int & iDepthDelta );
virtual void Update(float dTime) {};
- virtual void RecursiveUpdate(float dTime);
+ virtual void RecursiveUpdate(float dTime, const MercuryMatrix& globalMatrix);
void ThreadedUpdate(float dTime);
@@ -170,10 +170,6 @@
// std::list< MercuryAsset* > m_render;
// std::list< MercuryAsset* > m_postrender;
- ///This will get the world space matrix
- const MercuryMatrix& FindGlobalMatrix() const;
- const MercuryMatrix& FindModelViewMatrix() const;
-
const MercuryMatrix * m_pGlobalMatrix;
const MercuryMatrix * m_pModelViewMatrix;
Modified: Mercury2/src/RenderGraph.cpp
===================================================================
--- Mercury2/src/RenderGraph.cpp 2010-05-19 16:42:33 UTC (rev 741)
+++ Mercury2/src/RenderGraph.cpp 2010-05-19 22:05:52 UTC (rev 742)
@@ -58,14 +58,10 @@
RenderGraphEntry* lastEntry = &entry;
// MercuryNode* rn = MercuryNode::Cast(node);
- //Update the Matrices
- node->m_pGlobalMatrix = &node->FindGlobalMatrix();
- node->m_pModelViewMatrix = &node->FindModelViewMatrix();
-
if ( node )
{
//found a new renderable
- entry.m_children.push_back( RenderGraphEntry(&(node->FindGlobalMatrix()), node) );
+ entry.m_children.push_back( RenderGraphEntry(&(node->GetGlobalMatrix()), node) );
lastEntry = &(entry.m_children.back());
}
Modified: Mercury2/src/TransformNode.cpp
===================================================================
--- Mercury2/src/TransformNode.cpp 2010-05-19 16:42:33 UTC (rev 741)
+++ Mercury2/src/TransformNode.cpp 2010-05-19 22:05:52 UTC (rev 742)
@@ -14,6 +14,8 @@
void TransformNode::Update(float dTime)
{
if (m_tainted) ComputeMatrix();
+ m_pGlobalMatrix = &m_globalMatrix;
+ m_pModelViewMatrix = &m_modelView;
}
void TransformNode::RecursivePreRender()
@@ -89,23 +91,9 @@
// m_scale[0], m_scale[1], m_scale[2] );
// local = t * local;
- m_globalMatrix = GetParentMatrix() * local;
+ m_globalMatrix = *m_pGlobalMatrix * local;
}
-const MercuryMatrix& TransformNode::GetParentMatrix() const
-{
- const MercuryNode* n = m_parent;
- const TransformNode* tn;
- while (n)
- {
- tn = TransformNode::Cast( n );
- if ( tn ) return tn->GetGlobalMatrix();
- n = n->Parent();
- }
-
- return MercuryMatrix::Identity();
-}
-
void TransformNode::RippleTaintDown(MercuryNode* node)
{
TransformNode* tn;
@@ -200,11 +188,6 @@
}
}
-const MercuryMatrix& TransformNode::GetGlobalMatrix() const
-{
- return m_globalMatrix;
-}
-
void RotatorNode::Update(float dTime)
{
MQuaternion r = GetRotation();
Modified: Mercury2/src/TransformNode.h
===================================================================
--- Mercury2/src/TransformNode.h 2010-05-19 16:42:33 UTC (rev 741)
+++ Mercury2/src/TransformNode.h 2010-05-19 22:05:52 UTC (rev 742)
@@ -23,11 +23,6 @@
inline const MercuryVertex& GetPosition() const { return m_position; }
inline const MQuaternion& GetRotation() const { return m_rotation; }
-// inline const MercuryMatrix& GetGlobalMatrix() const { return m_globalMatrix; }
- virtual const MercuryMatrix& GetGlobalMatrix() const;
- inline const MercuryMatrix& GetModelViewMatrix() const { return m_modelView; }
- const MercuryMatrix& GetParentMatrix() const;
-
void SetTaint(bool taint);
virtual void ComputeMatrix();
@@ -55,6 +50,7 @@
// MercuryMatrix m_localMatrix;
protected:
+ //these are the matrices that should be pointed to
MercuryMatrix m_modelView;
MercuryMatrix m_globalMatrix;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-19 16:42:39
|
Revision: 741
http://hgengine.svn.sourceforge.net/hgengine/?rev=741&view=rev
Author: axlecrusher
Date: 2010-05-19 16:42:33 +0000 (Wed, 19 May 2010)
Log Message:
-----------
should be constant and public
Modified Paths:
--------------
Mercury2/src/MercuryMatrix.cpp
Mercury2/src/MercuryMatrix.h
Modified: Mercury2/src/MercuryMatrix.cpp
===================================================================
--- Mercury2/src/MercuryMatrix.cpp 2010-05-18 20:22:07 UTC (rev 740)
+++ Mercury2/src/MercuryMatrix.cpp 2010-05-19 16:42:33 UTC (rev 741)
@@ -296,7 +296,7 @@
}
-MercuryMatrix MercuryMatrix::IdentityMatrix;
+const MercuryMatrix MercuryMatrix::IdentityMatrix;
/*
* Copyright (c) 2006-2009 Joshua Allen
Modified: Mercury2/src/MercuryMatrix.h
===================================================================
--- Mercury2/src/MercuryMatrix.h 2010-05-18 20:22:07 UTC (rev 740)
+++ Mercury2/src/MercuryMatrix.h 2010-05-19 16:42:33 UTC (rev 741)
@@ -41,7 +41,6 @@
// FloatRow m_matrix[4];
FloatRow* m_matrix;
- static MercuryMatrix IdentityMatrix;
public:
MercuryMatrix();
MercuryMatrix(const MercuryMatrix& m);
@@ -84,6 +83,8 @@
void LoadIdentity();
void Print() const;
+
+ const static MercuryMatrix IdentityMatrix;
};
static InstanceCounter<MercuryMatrixMemory> MMMcounter("MercuryMatrixMemory");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-18 20:22:15
|
Revision: 740
http://hgengine.svn.sourceforge.net/hgengine/?rev=740&view=rev
Author: axlecrusher
Date: 2010-05-18 20:22:07 +0000 (Tue, 18 May 2010)
Log Message:
-----------
Try new hash function
Modified Paths:
--------------
Mercury2/src/MercuryString.cpp
Modified: Mercury2/src/MercuryString.cpp
===================================================================
--- Mercury2/src/MercuryString.cpp 2010-05-18 20:21:39 UTC (rev 739)
+++ Mercury2/src/MercuryString.cpp 2010-05-18 20:22:07 UTC (rev 740)
@@ -348,7 +348,7 @@
}
unsigned int MString::hash() const
-{
+{/*
unsigned int ret = 0;
unsigned int i;
unsigned int j = size()>>2;
@@ -359,6 +359,15 @@
ret += (unsigned int)(unsigned char)m_sCur[i];
return ret;
+ */
+ unsigned long hash = 5381;
+ int c;
+ unsigned char* s = (unsigned char*)m_sCur;
+
+ while ( (c = *s++) )
+ hash = hash * 33 ^ c;
+
+ return hash;
}
void MString::resize( unsigned int size )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-18 20:21:45
|
Revision: 739
http://hgengine.svn.sourceforge.net/hgengine/?rev=739&view=rev
Author: axlecrusher
Date: 2010-05-18 20:21:39 +0000 (Tue, 18 May 2010)
Log Message:
-----------
fix linux warnings
Modified Paths:
--------------
Mercury2/src/MercuryMath.h
Modified: Mercury2/src/MercuryMath.h
===================================================================
--- Mercury2/src/MercuryMath.h 2010-05-18 20:14:49 UTC (rev 738)
+++ Mercury2/src/MercuryMath.h 2010-05-18 20:21:39 UTC (rev 739)
@@ -2,6 +2,8 @@
#define _MERCURYMATH_H
#include <math.h>
+#include <string.h>
+
#ifdef HGENGINE
#ifndef WIN32
#include <configuration.h>
@@ -114,7 +116,9 @@
//http://graphics.stanford.edu/~seander/bithacks.html
inline unsigned int SetBit(unsigned int x, unsigned int mask, bool t)
{
+#if defined(WIN32)
#pragma warning( disable : 4804 )
+#endif
return ((x & ~mask) | (-t & mask)); /*superscalar CPU version*/
}
inline bool GetBit(unsigned int x, unsigned int mask) { return ((x & mask)>0); }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-18 20:14:56
|
Revision: 738
http://hgengine.svn.sourceforge.net/hgengine/?rev=738&view=rev
Author: axlecrusher
Date: 2010-05-18 20:14:49 +0000 (Tue, 18 May 2010)
Log Message:
-----------
fix warnings
Modified Paths:
--------------
Mercury2/modules/Cu2.cpp
Mercury2/modules/ParticleEmitter.cpp
Mercury2/modules/TextNode.cpp
Mercury2/src/DataTypes/MTriangle.cpp
Mercury2/src/MercuryInput.cpp
Mercury2/src/MercurySound.cpp
Mercury2/src/MercurySound.h
Mercury2/src/MercuryValue.cpp
Mercury2/src/Quad.cpp
Modified: Mercury2/modules/Cu2.cpp
===================================================================
--- Mercury2/modules/Cu2.cpp 2010-05-18 20:01:48 UTC (rev 737)
+++ Mercury2/modules/Cu2.cpp 2010-05-18 20:14:49 UTC (rev 738)
@@ -62,8 +62,8 @@
for( unsigned button = 0; button < 3; button++ )
{
unsigned char Mask = 1<<button;
- bool bWasDown = iLastButtonMask & Mask;
- bool bIsDown = iCurrentButtonMask & Mask;
+ bool bWasDown = GetBit(iLastButtonMask,Mask);
+ bool bIsDown = GetBit(iCurrentButtonMask,Mask);
if( bWasDown && !bIsDown )
{
//XXX: When we release outside - we want to propogate that information, and that can be tricky..
@@ -396,8 +396,8 @@
{
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 fxRangeMin = (float)atof( m_sxRangeMin.c_str() );
+ float fxRangeMax = m_sxRangeMax.length()?(float)atof( m_sxRangeMax.c_str() ):GetW();
float fX = ( float(x) / float(GetW()-1) ) * (fxRangeMax - fxRangeMin) + fxRangeMin;
MESSAGEMAN.GetValue( m_sAssociatedValueX )->SetFloat( fX );
@@ -405,8 +405,8 @@
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 fyRangeMin = (float)atof( m_syRangeMin.c_str() );
+ float fyRangeMax = m_syRangeMax.length()?(float)atof( m_syRangeMax.c_str() ):GetW();
float fY = ( float(y) / float(GetH()-1) ) * (fyRangeMax - fyRangeMin) + fyRangeMin;
MESSAGEMAN.GetValue( m_sAssociatedValueY )->SetFloat( fY );
@@ -446,9 +446,9 @@
{
glDisable( GL_TEXTURE_2D );
if( m_bDown )
- glColor3f( 0.3, 0.3, 0.3 );
+ glColor3f( 0.3f, 0.3f, 0.3f );
else
- glColor3f( 0.5, 0.5, 0.5 );
+ glColor3f( 0.5f, 0.5f, 0.5f );
glBegin( GL_QUADS );
glVertex2f( 1., 1. );
@@ -460,17 +460,17 @@
glLineWidth( 2 );
glBegin( GL_LINES );
if( m_bDown )
- glColor3f( 0.1, 0.1, 0.1 );
+ glColor3f( 0.1f, 0.1f, 0.1f );
else
- glColor3f( 0.7, 0.7, 0.7 );
+ glColor3f( 0.7f, 0.7f, 0.7f );
glVertex2f( 1, 1 );
glVertex2f( 1, GetH()-1 );
glVertex2f( 1, GetH()-1 );
glVertex2f( GetW()-2, GetH()-1 );
if( !m_bDown )
- glColor3f( 0.1, 0.1, 0.1 );
+ glColor3f( 0.1f, 0.1f, 0.1f );
else
- glColor3f( 0.7, 0.7, 0.7 );
+ glColor3f( 0.7f, 0.7f, 0.7f );
glVertex2f( GetW()-1, GetH()-2 );
glVertex2f( GetW()-1, 1 );
glVertex2f( GetW()-1, 1 );
@@ -618,12 +618,12 @@
glLineWidth( 2 );
glBegin( GL_LINES );
- glColor3f( 0.7, 0.7, 0.7 );
+ glColor3f( 0.7f, 0.7f, 0.7f );
glVertex2f( 1, 1 );
glVertex2f( 1, GetH()-1 );
glVertex2f( 1, GetH()-1 );
glVertex2f( GetW()-2, GetH()-1 );
- glColor3f( 0.1, 0.1, 0.1 );
+ glColor3f( 0.1f, 0.1f, 0.1f );
glVertex2f( GetW()-1, GetH()-2 );
glVertex2f( GetW()-1, 1 );
glVertex2f( GetW()-1, 1 );
@@ -633,7 +633,7 @@
if( HasFocus() )
glColor3f( 0., 0., 1. );
else
- glColor3f( .3, .3, .3 );
+ glColor3f( .3f, .3f, .3f );
glBegin( GL_QUADS );
glVertex2f( 2., GetH()-19 );
Modified: Mercury2/modules/ParticleEmitter.cpp
===================================================================
--- Mercury2/modules/ParticleEmitter.cpp 2010-05-18 20:01:48 UTC (rev 737)
+++ Mercury2/modules/ParticleEmitter.cpp 2010-05-18 20:14:49 UTC (rev 738)
@@ -113,8 +113,8 @@
}
ParticleEmitter::ParticleEmitter()
- :base(), m_maxParticles(50), m_age(0), m_emitDelay(0.1), m_lifespan(0),
- m_particlesEmitted(0), m_particleMinLife(0.1), m_particleMaxLife(5),
+ :base(), m_maxParticles(50), m_age(0), m_emitDelay(0.1f), m_lifespan(0),
+ m_particlesEmitted(0), m_particleMinLife(0.1f), m_particleMaxLife(5.0f),
m_particles(NULL), GenerateParticlesClbk(NULL),
m_dirtyVBO(0)
{
@@ -184,8 +184,8 @@
p->m_lifespan = m_particleMinLife;
p->m_lifespan += (rand()%(int(m_particleMaxLife*1000) - int(m_particleMinLife*1000)))/1000.0f;
- p->m_rand1 = rand()%100000;
- p->m_rand2 = rand()%100000;
+ p->m_rand1 = float(rand()%100000);
+ p->m_rand2 = float(rand()%100000);
// +((rand()%((m_particleMaxLife*1000)-(m_particleMinLife*1000)))/1000.0f);
Modified: Mercury2/modules/TextNode.cpp
===================================================================
--- Mercury2/modules/TextNode.cpp 2010-05-18 20:01:48 UTC (rev 737)
+++ Mercury2/modules/TextNode.cpp 2010-05-18 20:14:49 UTC (rev 738)
@@ -249,7 +249,7 @@
float offset = m_fTextWidth - fEndOfLine;
offset/=2;
if( m_fTextWidth > BIG_NUMBER )
- offset = -fEndOfLine/2.;
+ offset = -fEndOfLine/2.0f;
for( unsigned j = iLineStart; j < i; j++ )
chars[j].xps += offset;
} else if( m_alignment == FIT_FULL )
Modified: Mercury2/src/DataTypes/MTriangle.cpp
===================================================================
--- Mercury2/src/DataTypes/MTriangle.cpp 2010-05-18 20:01:48 UTC (rev 737)
+++ Mercury2/src/DataTypes/MTriangle.cpp 2010-05-18 20:14:49 UTC (rev 738)
@@ -77,7 +77,7 @@
v[0] = m_verts[1] - m_verts[0];
v[1] = m_verts[2] - m_verts[0];
MercuryVector r( v[0].CrossProduct( v[1] ) );
- return r.Length() * 0.5;
+ return r.Length() * 0.5f;
}
bool MTriangle::operator == (const MTriangle& rhs) const
@@ -92,8 +92,8 @@
{
float minX, minY, minZ;
float maxX, maxY, maxZ;
- minX=minY=minZ = 9999999999999;
- maxX=maxY=maxZ = -9999999999999;
+ minX=minY=minZ = 9999999999999.0f;
+ maxX=maxY=maxZ = -9999999999999.0f;
for (uint8_t i = 0; i<3; ++i)
{
@@ -109,7 +109,7 @@
MercuryVertex center( (maxX+minX)/2.0f, (maxY+minY)/2.0f, (maxZ+minZ)/2.0f );
//extends
- MercuryVertex extend( (maxX-minX)/2.0, (maxY-minY)/2.0, (maxZ-minZ)/2.0 );
+ MercuryVertex extend( (maxX-minX)/2.0f, (maxY-minY)/2.0f, (maxZ-minZ)/2.0f );
return BoundingBox(center, extend);
}
Modified: Mercury2/src/MercuryInput.cpp
===================================================================
--- Mercury2/src/MercuryInput.cpp 2010-05-18 20:01:48 UTC (rev 737)
+++ Mercury2/src/MercuryInput.cpp 2010-05-18 20:14:49 UTC (rev 738)
@@ -26,8 +26,8 @@
mi->buttons.motion = bMotionEvent;
currentButtonMasks = buttons;
- GlobalMouseX_Set.Set( dx );
- GlobalMouseY_Set.Set( dy );
+ GlobalMouseX_Set.Set( (float)dx );
+ GlobalMouseY_Set.Set( (float)dy );
GlobalMouseB_Set.Set( currentButtonMasks.data );
POST_MESSAGE( INPUTEVENT_MOUSE, mi, 0 );
Modified: Mercury2/src/MercurySound.cpp
===================================================================
--- Mercury2/src/MercurySound.cpp 2010-05-18 20:01:48 UTC (rev 737)
+++ Mercury2/src/MercurySound.cpp 2010-05-18 20:14:49 UTC (rev 738)
@@ -134,7 +134,7 @@
//XXX: CONSIDER MUTEXING THIS AREA, AND USING THE SAME MUTEX IN SampleHoldCalcand Attac/Detach sound.
float ftd = m_tLastTrip.Touch();
- iLastCountDifference = ftd * fSPS;
+ iLastCountDifference = int(ftd * fSPS);
for( int j = 0; j < iCount * iChannels; ++j )
cBufferToFill[j] = 0;
Modified: Mercury2/src/MercurySound.h
===================================================================
--- Mercury2/src/MercurySound.h 2010-05-18 20:01:48 UTC (rev 737)
+++ Mercury2/src/MercurySound.h 2010-05-18 20:14:49 UTC (rev 738)
@@ -71,7 +71,7 @@
//Useful tools
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); }
+ 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/MercuryValue.cpp
===================================================================
--- Mercury2/src/MercuryValue.cpp 2010-05-18 20:01:48 UTC (rev 737)
+++ Mercury2/src/MercuryValue.cpp 2010-05-18 20:14:49 UTC (rev 738)
@@ -74,8 +74,8 @@
{
switch( m_CurType )
{
- case TYPE_INT: return (int)m_Data.l;
- case TYPE_FLOAT: return m_Data.f;
+ case TYPE_INT: return m_Data.l;
+ case TYPE_FLOAT: return (int)m_Data.f;
case TYPE_STRING: return StrToInt(*m_Data.dataS);
default: return 0;
}
Modified: Mercury2/src/Quad.cpp
===================================================================
--- Mercury2/src/Quad.cpp 2010-05-18 20:01:48 UTC (rev 737)
+++ Mercury2/src/Quad.cpp 2010-05-18 20:14:49 UTC (rev 738)
@@ -89,19 +89,19 @@
//UV oriented so 0,0 is lower left and 1,0 upper right.
//this makes it so FBO images render correctly right out of the buffer, no flip needed
- m_vertexData[i++] = 0; m_vertexData[i++] = (m_bFlipV)?0:1;
- m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
+ m_vertexData[i++] = 0; m_vertexData[i++] = (m_bFlipV)?0:1.0f;
+ m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0f;
m_vertexData[i++] = lX; m_vertexData[i++] = lY; m_vertexData[i++] = zp;
- m_vertexData[i++] = 1; m_vertexData[i++] = (m_bFlipV)?0:1;
- m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
+ m_vertexData[i++] = 1; m_vertexData[i++] = (m_bFlipV)?0:1.0f;
+ m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0f;
m_vertexData[i++] = hX; m_vertexData[i++] = lY; m_vertexData[i++] = zp;
- m_vertexData[i++] = 1; m_vertexData[i++] = (m_bFlipV)?1:0;
- m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
+ m_vertexData[i++] = 1; m_vertexData[i++] = (m_bFlipV)?1.0f:0;
+ m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0f;
m_vertexData[i++] = hX; m_vertexData[i++] = hY; m_vertexData[i++] = zp;
- m_vertexData[i++] = 0; m_vertexData[i++] = (m_bFlipV)?1:0;
+ m_vertexData[i++] = 0; m_vertexData[i++] = (m_bFlipV)?1.0f:0;
m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
m_vertexData[i++] = lX; m_vertexData[i++] = hY; m_vertexData[i++] = zp;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-18 20:01:54
|
Revision: 737
http://hgengine.svn.sourceforge.net/hgengine/?rev=737&view=rev
Author: axlecrusher
Date: 2010-05-18 20:01:48 +0000 (Tue, 18 May 2010)
Log Message:
-----------
fix warnings
Modified Paths:
--------------
Mercury2/src/MercuryUtil.cpp
Modified: Mercury2/src/MercuryUtil.cpp
===================================================================
--- Mercury2/src/MercuryUtil.cpp 2010-05-18 19:58:51 UTC (rev 736)
+++ Mercury2/src/MercuryUtil.cpp 2010-05-18 20:01:48 UTC (rev 737)
@@ -1,355 +1,355 @@
-#include <MercuryUtil.h>
-#include <MercuryFile.h>
-#include <Mint.h>
-#include <MercuryVector.h>
-#include <MercuryBacktrace.h>
-#include <math.h>
-
-#ifdef WIN32
-#include <Windows.h>
-#else
-#include <unistd.h>
-#endif
-
-MString ConvertToCFormat( const MString & ncf )
-{
- MString ret;
- const char* nccf = ncf.c_str();
-
- for ( int i = 0; (unsigned)i < ncf.length(); i++ )
- {
- switch ( nccf[i] )
- {
- case '\t': ret += "\\t"; break;
- case '\n': ret += "\\n"; break;
- case '\r': ret += "\\r"; break;
- case '\f': ret += "\\f"; break;
- case '\b': ret += "\\b"; break;
- case '\\': ret += "\\\\"; break;
- case '\'': ret += "\\\'"; break;
- case '\"': ret += "\\\""; break;
- default:
- if( nccf[i] < 32 )
- {
- ret += "\\";
- ret += ((unsigned char)nccf[i]/64)%8 + '0';
- ret += ((unsigned char)nccf[i]/8)%8 + '0';
- ret += (unsigned char)nccf[i]%8 + '0';
- } else
- ret += nccf[i];
- }
- }
- return ret;
-}
-
-MString ConvertToUnformatted( const MString & cf )
-{
- MString ret;
- const char* ccf = cf.c_str();
-
- for ( int i = 0; (unsigned)i < cf.length(); i++ )
- {
- switch ( ccf[i] )
- {
- case '\\':
- i++;
- if ( (unsigned)i >= cf.length() )
- return ret;
- switch ( ccf[i] )
- {
- case 't': ret += '\t'; break;
- case 'n': ret += '\n'; break;
- case 'r': ret += '\r'; break;
- case 'f': ret += '\f'; break;
- case 'b': ret += '\b'; break;
- case '\\': ret += '\\'; break;
- case '\'': ret += '\''; break;
- case '\"': ret += '\"'; break;
- default:
- if( ccf[i] >= '0' && ccf[i] <= '7' )
- {
- char c = ccf[i] - '0';
- if( ccf[i+1] >= '0' && ccf[i+1] <= '8' )
- {
- i++;
- c = c * 8 + ccf[i] - '0';
- }
- if( ccf[i+1] >= '0' && ccf[i+1] <= '8' )
- {
- i++;
- c = c * 8 + ccf[i] - '0';
- }
- ret += c;
- }
- }
- break;
- default:
- ret += ccf[i];
- }
- }
- return ret;
-}
-
-MString ToUpper(const MString& s)
-{
- MString t = s;
- char * ti = (char*)t.c_str();
- for (unsigned long i = 0; i < s.length(); ++i)
- {
- if( ti[i] >= 'a' && ti[i] <= 'z' )
- ti[i] -= ( 'a' - 'A' );
- }
- return t;
-}
-
-MString ToLower(const MString & s)
-{
- MString t = s;
- char * ti = (char*)t.c_str();
- for (unsigned long i = 0; i < s.length(); ++i)
- {
- if( ti[i] >= 'A' && ti[i] <= 'Z' )
- ti[i] += ( 'a' - 'A' );
- }
- return t;
-}
-
-MString ToProper(const MString & s)
-{
- if( s.length() == 0 )
- return "";
-
- MString t = s;
- char * ti = (char*)t.c_str();
-
- if( ti[0] >= 'a' && ti[0] <= 'z' )
- ti[0] -= ( 'a' - 'A' );
-
- for (unsigned long i = 1; i < s.length(); ++i)
- {
- if( ti[i] >= 'A' && ti[i] <= 'Z' )
- ti[i] += ( 'a' - 'A' );
- }
- return t;
-
-}
-
-
-
-float StrToFloat(const MString & s, float d)
-{
- float x = d;
-#if defined( WIN32 ) && !defined( LEAN_HG )
- if ( s.length() > 0) sscanf_s(s.c_str(), "%f", &x);
-#else
- if ( s.length() > 0) sscanf(s.c_str(), "%f", &x);
-#endif
- return x;
-}
-
-int32_t StrToInt(const MString & s, int32_t d)
-{
- int32_t x = d;
-#if defined( WIN32 ) && !defined( LEAN_HG )
- if ( s.length() > 0) sscanf_s(s.c_str(), "%d", &x);
-#else
- if ( s.length() > 0) sscanf(s.c_str(), "%d", &x);
-#endif
- return x;
-}
-
-bool StrToBool( const MString & s, bool d )
-{
- MString tmpret = s;
-
- tmpret = ToUpper( tmpret );
- if( tmpret.compare( "TRUE" ) == 0 ) return 1;
- if( tmpret.compare( "FALSE" ) == 0 ) return 0;
- if( tmpret.compare( "ON" ) == 0 ) return 1;
- if( tmpret.compare( "OFF" ) == 0 ) return 0;
- if( tmpret.compare( "YES" ) == 0 ) return 1;
- if( tmpret.compare( "NO" ) == 0 ) return 0;
-
- return StrToInt( tmpret, d ) != 0;
-}
-
-
-void fail_m( const char * message, const char * file, int line )
-{
- char backtracebuffer[2048];
- //Probably should message box here somewhere in the event we're running on Windows.
- fprintf( stderr, "Fatal Error: \"%s\" in %s:%d\n", message, file, line );
- cnget_backtrace( 1, backtracebuffer, 2047 );
- puts( backtracebuffer );
- exit(-1);
-}
-
-void* mmemalign(size_t align, size_t size, void*& mem)
-{
- uintptr_t mask = ~(uintptr_t)(align - 1);
- mem = malloc(size+align-1);
- void *ptr = (void *)(((uintptr_t)mem+align-1) & mask);
- return ptr;
-}
-
-bool isAligned(size_t align, const void* mem)
-{
- return (uintptr_t(mem) % align) == 0;
-}
-
-long FileToString( const MString & sFileName, char * & data )
-{
- data = 0;
-
- MercuryFile * f = FILEMAN.Open( sFileName );
- if( !f ) return -1;
-
- int length = f->Length();
-
- data = (char*)malloc( length + 1 );
-
- if( !data )
- {
- data = 0;
- delete f;
- return -1;
- }
-
- int r = f->Read( data, length );
-
- delete f;
-
- if( r != length )
- {
- free( data );
- data = 0;
- return -1;
- }
-
- return length;
-}
-
-bool StringToFile( const MString & sFileName, const MString & data )
-{
- MercuryFile * f = FILEMAN.Open( sFileName, MFP_WRITE_ONLY );
- if( !f ) return false;
- f->Write( data.c_str(), data.length() );
- delete f;
- return true;
-}
+#include <MercuryUtil.h>
+#include <MercuryFile.h>
+#include <Mint.h>
+#include <MercuryVector.h>
+#include <MercuryBacktrace.h>
+#include <math.h>
-
-int GeneralUsePrimes[] = { 3, 13, 37, 73, 131, 229, 337, 821, 2477, 4594, 8941, 14797, 24953, 39041, 60811, 104729 };
-
-int GetAPrime( int ith )
-{
- return (ith<0)?3:(ith>15)?GeneralUsePrimes[15]:GeneralUsePrimes[ith];
-}
-
-//String processing functions
-long BytesUntil( const char* strin, const char * termin, long start, long slen, long termlen )
-{
- int i;
- for ( i = start; i < slen; i++ )
- for ( int j = 0; j < termlen; j++ )
- if ( termin[j] == strin[i] )
- return i - start;
- return i - start;
-}
-
-long BytesNUntil( const char* strin, const char * termin, long start, long slen, long termlen )
-{
- int i;
- for ( i = start; i < slen; i++ )
- {
- bool found = false;
- for ( int j = 0; j < termlen; j++ )
- {
- if ( termin[j] == strin[i] )
- found = true;
- }
- if ( !found )
- return i - start;
- }
- return i - start;
-}
-
-void SplitStrings( const MString & in, MVector < MString > & out,
- const char * termin, const char * whitespace,
- long termlen, long wslen )
-{
- const char * inStr = in.c_str();
- long curPos = 0;
- long inLen = in.length();
- while ( curPos < inLen )
- {
- curPos += BytesNUntil( inStr, whitespace, curPos, inLen, wslen );
- long NextPos = BytesUntil( inStr, termin, curPos, inLen, termlen );
- out.push_back( in.substr( curPos, NextPos ) );
- curPos += NextPos + 1;
- }
-}
-
-void msleep(uint32_t msec)
-{
-#ifdef WIN32
- Sleep(msec);
-#else
- usleep(msec*1000);
-#endif
-}
-
-float FLinear( float in, float slice )
-{
- float fret = (in - 0.5) * slice;
-
- if( fret > 0.5 ) fret = 0.5;
- else if( fret < -0.5 ) fret = -0.5;
- return fret + 0.5;
-}
-
-float FExponential( float in, float powx )
-{
- return pow( in, powx );
-}
-
-float FStep( float in, float stepplace )
-{
- return ( in < stepplace )?0:1;
-}
-
-float FSigmoid( float in, float fspeed )
-{
- float fi = in - 0.5;
- float fr = ( exp( fi * fspeed ) - 1 ) / ( exp( fi * fspeed ) + 1 );
- float smax = ( exp( fspeed * 0.5 ) - 1 ) / ( exp( fspeed * 0.5 ) + 1 );
- return (fr / smax) / 2. + 0.5;
-}
-
-
-/* Copyright (c) 2009, Joshua Allen and Charles Lohr
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the distribution.
- * - Neither the name of the Mercury Engine nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+#ifdef WIN32
+#include <Windows.h>
+#else
+#include <unistd.h>
+#endif
+
+MString ConvertToCFormat( const MString & ncf )
+{
+ MString ret;
+ const char* nccf = ncf.c_str();
+
+ for ( int i = 0; (unsigned)i < ncf.length(); i++ )
+ {
+ switch ( nccf[i] )
+ {
+ case '\t': ret += "\\t"; break;
+ case '\n': ret += "\\n"; break;
+ case '\r': ret += "\\r"; break;
+ case '\f': ret += "\\f"; break;
+ case '\b': ret += "\\b"; break;
+ case '\\': ret += "\\\\"; break;
+ case '\'': ret += "\\\'"; break;
+ case '\"': ret += "\\\""; break;
+ default:
+ if( nccf[i] < 32 )
+ {
+ ret += "\\";
+ ret += ((unsigned char)nccf[i]/64)%8 + '0';
+ ret += ((unsigned char)nccf[i]/8)%8 + '0';
+ ret += (unsigned char)nccf[i]%8 + '0';
+ } else
+ ret += nccf[i];
+ }
+ }
+ return ret;
+}
+
+MString ConvertToUnformatted( const MString & cf )
+{
+ MString ret;
+ const char* ccf = cf.c_str();
+
+ for ( int i = 0; (unsigned)i < cf.length(); i++ )
+ {
+ switch ( ccf[i] )
+ {
+ case '\\':
+ i++;
+ if ( (unsigned)i >= cf.length() )
+ return ret;
+ switch ( ccf[i] )
+ {
+ case 't': ret += '\t'; break;
+ case 'n': ret += '\n'; break;
+ case 'r': ret += '\r'; break;
+ case 'f': ret += '\f'; break;
+ case 'b': ret += '\b'; break;
+ case '\\': ret += '\\'; break;
+ case '\'': ret += '\''; break;
+ case '\"': ret += '\"'; break;
+ default:
+ if( ccf[i] >= '0' && ccf[i] <= '7' )
+ {
+ char c = ccf[i] - '0';
+ if( ccf[i+1] >= '0' && ccf[i+1] <= '8' )
+ {
+ i++;
+ c = c * 8 + ccf[i] - '0';
+ }
+ if( ccf[i+1] >= '0' && ccf[i+1] <= '8' )
+ {
+ i++;
+ c = c * 8 + ccf[i] - '0';
+ }
+ ret += c;
+ }
+ }
+ break;
+ default:
+ ret += ccf[i];
+ }
+ }
+ return ret;
+}
+
+MString ToUpper(const MString& s)
+{
+ MString t = s;
+ char * ti = (char*)t.c_str();
+ for (unsigned long i = 0; i < s.length(); ++i)
+ {
+ if( ti[i] >= 'a' && ti[i] <= 'z' )
+ ti[i] -= ( 'a' - 'A' );
+ }
+ return t;
+}
+
+MString ToLower(const MString & s)
+{
+ MString t = s;
+ char * ti = (char*)t.c_str();
+ for (unsigned long i = 0; i < s.length(); ++i)
+ {
+ if( ti[i] >= 'A' && ti[i] <= 'Z' )
+ ti[i] += ( 'a' - 'A' );
+ }
+ return t;
+}
+
+MString ToProper(const MString & s)
+{
+ if( s.length() == 0 )
+ return "";
+
+ MString t = s;
+ char * ti = (char*)t.c_str();
+
+ if( ti[0] >= 'a' && ti[0] <= 'z' )
+ ti[0] -= ( 'a' - 'A' );
+
+ for (unsigned long i = 1; i < s.length(); ++i)
+ {
+ if( ti[i] >= 'A' && ti[i] <= 'Z' )
+ ti[i] += ( 'a' - 'A' );
+ }
+ return t;
+
+}
+
+
+
+float StrToFloat(const MString & s, float d)
+{
+ float x = d;
+#if defined( WIN32 ) && !defined( LEAN_HG )
+ if ( s.length() > 0) sscanf_s(s.c_str(), "%f", &x);
+#else
+ if ( s.length() > 0) sscanf(s.c_str(), "%f", &x);
+#endif
+ return x;
+}
+
+int32_t StrToInt(const MString & s, int32_t d)
+{
+ int32_t x = d;
+#if defined( WIN32 ) && !defined( LEAN_HG )
+ if ( s.length() > 0) sscanf_s(s.c_str(), "%d", &x);
+#else
+ if ( s.length() > 0) sscanf(s.c_str(), "%d", &x);
+#endif
+ return x;
+}
+
+bool StrToBool( const MString & s, bool d )
+{
+ MString tmpret = s;
+
+ tmpret = ToUpper( tmpret );
+ if( tmpret.compare( "TRUE" ) == 0 ) return 1;
+ if( tmpret.compare( "FALSE" ) == 0 ) return 0;
+ if( tmpret.compare( "ON" ) == 0 ) return 1;
+ if( tmpret.compare( "OFF" ) == 0 ) return 0;
+ if( tmpret.compare( "YES" ) == 0 ) return 1;
+ if( tmpret.compare( "NO" ) == 0 ) return 0;
+
+ return StrToInt( tmpret, d ) != 0;
+}
+
+
+void fail_m( const char * message, const char * file, int line )
+{
+ char backtracebuffer[2048];
+ //Probably should message box here somewhere in the event we're running on Windows.
+ fprintf( stderr, "Fatal Error: \"%s\" in %s:%d\n", message, file, line );
+ cnget_backtrace( 1, backtracebuffer, 2047 );
+ puts( backtracebuffer );
+ exit(-1);
+}
+
+void* mmemalign(size_t align, size_t size, void*& mem)
+{
+ uintptr_t mask = ~(uintptr_t)(align - 1);
+ mem = malloc(size+align-1);
+ void *ptr = (void *)(((uintptr_t)mem+align-1) & mask);
+ return ptr;
+}
+
+bool isAligned(size_t align, const void* mem)
+{
+ return (uintptr_t(mem) % align) == 0;
+}
+
+long FileToString( const MString & sFileName, char * & data )
+{
+ data = 0;
+
+ MercuryFile * f = FILEMAN.Open( sFileName );
+ if( !f ) return -1;
+
+ int length = f->Length();
+
+ data = (char*)malloc( length + 1 );
+
+ if( !data )
+ {
+ data = 0;
+ delete f;
+ return -1;
+ }
+
+ int r = f->Read( data, length );
+
+ delete f;
+
+ if( r != length )
+ {
+ free( data );
+ data = 0;
+ return -1;
+ }
+
+ return length;
+}
+
+bool StringToFile( const MString & sFileName, const MString & data )
+{
+ MercuryFile * f = FILEMAN.Open( sFileName, MFP_WRITE_ONLY );
+ if( !f ) return false;
+ f->Write( data.c_str(), data.length() );
+ delete f;
+ return true;
+}
+
+
+int GeneralUsePrimes[] = { 3, 13, 37, 73, 131, 229, 337, 821, 2477, 4594, 8941, 14797, 24953, 39041, 60811, 104729 };
+
+int GetAPrime( int ith )
+{
+ return (ith<0)?3:(ith>15)?GeneralUsePrimes[15]:GeneralUsePrimes[ith];
+}
+
+//String processing functions
+long BytesUntil( const char* strin, const char * termin, long start, long slen, long termlen )
+{
+ int i;
+ for ( i = start; i < slen; i++ )
+ for ( int j = 0; j < termlen; j++ )
+ if ( termin[j] == strin[i] )
+ return i - start;
+ return i - start;
+}
+
+long BytesNUntil( const char* strin, const char * termin, long start, long slen, long termlen )
+{
+ int i;
+ for ( i = start; i < slen; i++ )
+ {
+ bool found = false;
+ for ( int j = 0; j < termlen; j++ )
+ {
+ if ( termin[j] == strin[i] )
+ found = true;
+ }
+ if ( !found )
+ return i - start;
+ }
+ return i - start;
+}
+
+void SplitStrings( const MString & in, MVector < MString > & out,
+ const char * termin, const char * whitespace,
+ long termlen, long wslen )
+{
+ const char * inStr = in.c_str();
+ long curPos = 0;
+ long inLen = in.length();
+ while ( curPos < inLen )
+ {
+ curPos += BytesNUntil( inStr, whitespace, curPos, inLen, wslen );
+ long NextPos = BytesUntil( inStr, termin, curPos, inLen, termlen );
+ out.push_back( in.substr( curPos, NextPos ) );
+ curPos += NextPos + 1;
+ }
+}
+
+void msleep(uint32_t msec)
+{
+#ifdef WIN32
+ Sleep(msec);
+#else
+ usleep(msec*1000);
+#endif
+}
+
+float FLinear( float in, float slice )
+{
+ float fret = (in - 0.5f) * slice;
+
+ if( fret > 0.5f ) fret = 0.5f;
+ else if( fret < -0.5f ) fret = -0.5f;
+ return fret + 0.5f;
+}
+
+float FExponential( float in, float powx )
+{
+ return pow( in, powx );
+}
+
+float FStep( float in, float stepplace )
+{
+ return ( in < stepplace )?0.0f:1.0f;
+}
+
+float FSigmoid( float in, float fspeed )
+{
+ float fi = in - 0.5f;
+ float fr = ( exp( fi * fspeed ) - 1.0f ) / ( exp( fi * fspeed ) + 1.0f );
+ float smax = ( exp( fspeed * 0.5f ) - 1.0f ) / ( exp( fspeed * 0.5f ) + 1.0f );
+ return (fr / smax) / 2.0f + 0.5f;
+}
+
+
+/* Copyright (c) 2009, Joshua Allen and Charles Lohr
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Mercury Engine nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-18 19:58:58
|
Revision: 736
http://hgengine.svn.sourceforge.net/hgengine/?rev=736&view=rev
Author: axlecrusher
Date: 2010-05-18 19:58:51 +0000 (Tue, 18 May 2010)
Log Message:
-----------
fix warnings
Modified Paths:
--------------
Mercury2/src/Win32Window.cpp
Modified: Mercury2/src/Win32Window.cpp
===================================================================
--- Mercury2/src/Win32Window.cpp 2010-05-18 19:58:20 UTC (rev 735)
+++ Mercury2/src/Win32Window.cpp 2010-05-18 19:58:51 UTC (rev 736)
@@ -244,9 +244,9 @@
GetWindowRect(m_hwnd, &rect);
GetCursorPos(&pos);
ScreenToClient(m_hwnd, &pos );
- bool left = message.wParam&MK_LBUTTON;
- bool right = message.wParam&MK_RBUTTON;
- bool center = message.wParam&MK_MBUTTON;
+ bool left = GetBit(message.wParam,MK_LBUTTON);
+ bool right = GetBit(message.wParam,MK_RBUTTON);
+ bool center = GetBit(message.wParam,MK_MBUTTON);
bool su = 0;
bool sd = 0;
int px = pos.x;// - rect.left - borderx;
@@ -295,16 +295,16 @@
case WM_RBUTTONUP:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
- MouseInput::ProcessMouseInput( lastx, lasty, message.wParam&MK_LBUTTON,
- message.wParam&MK_RBUTTON, message.wParam&MK_MBUTTON, 0, 0, false);
+ MouseInput::ProcessMouseInput( lastx, lasty, GetBit(message.wParam,MK_LBUTTON),
+ GetBit(message.wParam,MK_RBUTTON), GetBit(message.wParam,MK_MBUTTON), 0, 0, false);
break;
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);
+ MouseInput::ProcessMouseInput( lastx, lasty, GetBit(message.wParam,MK_LBUTTON),
+ GetBit(message.wParam,MK_RBUTTON), GetBit(message.wParam,MK_MBUTTON), (cx>0), (cx<0), false);
+ MouseInput::ProcessMouseInput( lastx, lasty, GetBit(message.wParam,MK_LBUTTON),
+ GetBit(message.wParam,MK_RBUTTON), GetBit(message.wParam,MK_MBUTTON), 0, 0, false);
break;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-18 19:58:27
|
Revision: 735
http://hgengine.svn.sourceforge.net/hgengine/?rev=735&view=rev
Author: axlecrusher
Date: 2010-05-18 19:58:20 +0000 (Tue, 18 May 2010)
Log Message:
-----------
Faster matrix transpose and memcpy apparently is faster, when optimize build
Modified Paths:
--------------
Mercury2/src/MercuryMath.cpp
Mercury2/src/MercuryMath.h
Mercury2/src/MercuryMatrix.cpp
Mercury2/src/MercuryMatrix.h
Modified: Mercury2/src/MercuryMath.cpp
===================================================================
--- Mercury2/src/MercuryMath.cpp 2010-05-18 14:48:33 UTC (rev 734)
+++ Mercury2/src/MercuryMath.cpp 2010-05-18 19:58:20 UTC (rev 735)
@@ -2,10 +2,15 @@
#include "MercuryMath.h"
//the SSE version of this was really slow, this is quicker
-void TransposeMatrix( FloatRow* m )
+
+#ifndef USE_SSE
+
+//Generic Math functions. Compile these if you can not use optimized functions.
+
+void TransposeMatrix( const FloatRow* matrix, FloatRow* out )
{
float tmp;
- float *_m = (float*)m;
+ float *_m = (float*)out;
tmp = _m[1];
_m[1] = _m[4];
@@ -30,10 +35,6 @@
_m[14] = tmp;
}
-#ifndef USE_SSE
-
-//Generic Math functions. Compile these if you can not use optimized functions.
-
void ZeroFloatRow(FloatRow& r)
{
Copy4f(&r, &gfrZero );
@@ -71,21 +72,6 @@
Copy4f(out,r);
}
-void Copy4f( void * dest, const void * source )
-{
- COPY<float,4>((float*)source, (float*)dest);
-}
-
-void Copy8f( void * dest, const void * source )
-{
- COPY<float,8>((float*)source, (float*)dest);
-}
-
-void Copy16f( void * dest, const void * source )
-{
- COPY<float,16>((float*)source, (float*)dest);
-}
-
void MatrixMultiply4f ( const FloatRow* in1a, const FloatRow* in2a, FloatRow* outa)
{
const float *in1 = *in1a;
@@ -216,30 +202,6 @@
_mm_store_ps(out,o);
}
-void Copy4f( void * dest, const void * source )
-{
- _mm_stream_ps(((float*)dest),((__m128*)source)[0]);
-}
-
-void Copy8f( void * dest, const void * source )
-{
- _mm_stream_ps(((float*)dest),((__m128*)source)[0]);
- _mm_stream_ps(((float*)dest)+4,((__m128*)source)[1]);
-}
-
-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]);
- _mm_stream_ps(((float*)dest)+12,((__m128*)source)[3]);
-}
-
void MatrixMultiply4f( const FloatRow* in1, const FloatRow* in2, FloatRow* out)
{
unsigned int y = 0;
@@ -399,7 +361,7 @@
__m128 r[2];
- r[0] = _mm_set_ps(0.0f,0.0f,0.0f,1.0f);
+ r[0] = _mm_set_ss(1.0f);
_mm_storer_ps(m+12,r[0]); //reverse r[0]
r[1] = _mm_shuffle_ps(r[0], r[0], _MM_SHUFFLE(1,1,0,1));
@@ -409,9 +371,42 @@
_mm_store_ps(m+4, r[1]);
}
+void TransposeMatrix( const FloatRow* matrix, FloatRow* out )
+{
+ //compiler acts better when we send in 2 parameter rather than 1
+ __m128 m[4],r[4];
+
+ m[0] = _mm_load_ps(matrix[0]);
+ m[1] = _mm_load_ps(matrix[1]);
+ m[2] = _mm_load_ps(matrix[2]);
+ m[3] = _mm_load_ps(matrix[3]);
+
+ r[0] = _mm_movelh_ps(m[0],m[1]);
+ r[1] = _mm_movelh_ps(m[2],m[3]);
+ r[2] = _mm_movehl_ps(m[1],m[0]);
+ r[3] = _mm_movehl_ps(m[3],m[2]);
+ //done with m matrix, we can reuse it now
+
+ m[0] = _mm_shuffle_ps(r[0], r[0], _MM_SHUFFLE(3,1,2,0)); //produce beginning of new row 0 and 1
+ m[1] = _mm_shuffle_ps(r[1], r[1], _MM_SHUFFLE(3,1,2,0)); //produce ending of new row 0 and 1
+ m[2] = _mm_shuffle_ps(r[2], r[2], _MM_SHUFFLE(3,1,2,0)); //produce beginning of new row 2 and 3
+ m[3] = _mm_shuffle_ps(r[3], r[3], _MM_SHUFFLE(3,1,2,0)); //produce ending of new row 2 and 3
+
+ r[0] = _mm_movelh_ps(m[0],m[1]); //row 0 is done
+ r[2] = _mm_movelh_ps(m[2],m[3]); //row 2 is done
+ r[1] = _mm_movehl_ps(m[1],m[0]); //row 1 is done
+ r[3] = _mm_movehl_ps(m[3],m[2]); //row 3 is done
+
+ _mm_store_ps(out[0], r[0]);
+ _mm_store_ps(out[1], r[1]);
+ _mm_store_ps(out[2], r[2]);
+ _mm_store_ps(out[3], r[3]);
+}
+
void MMCrossProduct( const FloatRow& r1, const FloatRow& r2, FloatRow& result)
{
- __m128 a,b,c,d,r;//using more registers is faster
+ //using more registers is faster(8 maximum)
+ __m128 a,b,c,d,r;
__m128 t1,t2;
//unaligned load, vectors are not aligned
Modified: Mercury2/src/MercuryMath.h
===================================================================
--- Mercury2/src/MercuryMath.h 2010-05-18 14:48:33 UTC (rev 734)
+++ Mercury2/src/MercuryMath.h 2010-05-18 19:58:20 UTC (rev 735)
@@ -102,18 +102,22 @@
void Div4f(const FloatRow& first, const FloatRow& second, FloatRow& out);
void Add4f(const FloatRow& first, const FloatRow& second, FloatRow& out);
void Sub4f(const FloatRow& first, const FloatRow& second, FloatRow& out);
-void Copy4f( void * dest, const void * source );
-void Copy8f( void * dest, const void * source );
-void Copy16f( void * dest, const void * source );
+inline void Copy4f( void * dest, const void * source ) { memcpy(dest,source,16); }
+inline void Copy8f( void * dest, const void * source ) { memcpy(dest,source,32); }
+inline void Copy16f( void * dest, const void * source ) { memcpy(dest,source,64); }
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 TransposeMatrix(const FloatRow* matrix, FloatRow* out);
void MMCrossProduct( const FloatRow& r1, const FloatRow& r2, FloatRow& result);
void LoadIdentity(FloatRow* matrix);
//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)>0)
+inline unsigned int SetBit(unsigned int x, unsigned int mask, bool t)
+{
+ #pragma warning( disable : 4804 )
+ return ((x & ~mask) | (-t & mask)); /*superscalar CPU version*/
+}
+inline bool GetBit(unsigned int x, unsigned int mask) { return ((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-05-18 14:48:33 UTC (rev 734)
+++ Mercury2/src/MercuryMatrix.cpp 2010-05-18 19:58:20 UTC (rev 735)
@@ -25,6 +25,18 @@
for (unsigned int i = 0; i < rows;i++)
m_free.push_back( m_data.Buffer()+i );
+/*
+ //test matrix transpose
+ MercuryMatrix test;
+ for (int i = 0; i < 16; ++i)
+ test.Ptr()[i] = i+1;
+
+ LOG.Write("before transpose\n");
+ test.Print();
+ test.Transpose();
+ LOG.Write("after Transpose\n");
+ test.Print();
+ */
}
FloatRow* MercuryMatrixMemory::GetNewMatrix()
@@ -45,26 +57,10 @@
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] );
- m_matrix[1] = _mm_load1_ps( &base_matrix_identity[4] );
- m_matrix[2] = _mm_load1_ps( &base_matrix_identity[8] );
- m_matrix[3] = _mm_load1_ps( &base_matrix_identity[12] );
-#else
- Copy16f(m_matrix[0], base_matrix_identity );
-#endif
-*/
-// *this = Identity();
+{
m_matrix = MercuryMatrixMemory::GetInstance().GetNewMatrix();
LoadIdentity();
}
@@ -292,6 +288,14 @@
return r;
}
+void MercuryMatrix::Transpose()
+{
+ //we know we will be operating on this data so try to go get it, 3-4x increase in speed.
+ PREFETCH((const char*)m_matrix,_MM_HINT_NTA);
+ TransposeMatrix( m_matrix, m_matrix );
+}
+
+
MercuryMatrix MercuryMatrix::IdentityMatrix;
/*
Modified: Mercury2/src/MercuryMatrix.h
===================================================================
--- Mercury2/src/MercuryMatrix.h 2010-05-18 14:48:33 UTC (rev 734)
+++ Mercury2/src/MercuryMatrix.h 2010-05-18 19:58:20 UTC (rev 735)
@@ -77,7 +77,7 @@
inline void Scale(const MercuryVertex& v) { Scale(v[0], v[1], v[2]); }
void Transotale( float tX, float tY, float tZ, float rX, float rY, float rZ, float sX, float sY, float sZ );
- inline void Transpose() { TransposeMatrix( m_matrix ); }
+ void Transpose();
void Zero();
static const MercuryMatrix& Identity();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-18 14:48:40
|
Revision: 734
http://hgengine.svn.sourceforge.net/hgengine/?rev=734&view=rev
Author: axlecrusher
Date: 2010-05-18 14:48:33 +0000 (Tue, 18 May 2010)
Log Message:
-----------
Faster matrix multiplication (7.3 time samples down to 1.8 in the profiler).
Much faster LoadIdentity function (6.58 to 0.34 time samples in the profiler).
Modified Paths:
--------------
Mercury2/src/MercuryMath.cpp
Mercury2/src/MercuryMath.h
Mercury2/src/MercuryMatrix.cpp
Modified: Mercury2/src/MercuryMath.cpp
===================================================================
--- Mercury2/src/MercuryMath.cpp 2010-05-17 23:58:27 UTC (rev 733)
+++ Mercury2/src/MercuryMath.cpp 2010-05-18 14:48:33 UTC (rev 734)
@@ -242,42 +242,114 @@
void MatrixMultiply4f( const FloatRow* in1, const FloatRow* in2, FloatRow* out)
{
- unsigned int y;
- __m128 xmm[4], a[4], b[4];
+ unsigned int y = 0;
+ __m128 xmm[4], b[4];
-// PREFETCH(in1, _MM_HINT_T0);
-// PREFETCH(in2, _MM_HINT_T1);
-// PREFETCH(out, _MM_HINT_T1);
+ b[3] = _mm_load_ps(in1[0]); //use b3 as temporary storage for matrix1 row1
+
+ //start loading matrix2
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]);
+
+ //load row1 of matrix1 into columns
+ xmm[0] = _mm_shuffle_ps (b[3], b[3], 0x00);
+ xmm[1] = _mm_shuffle_ps (b[3], b[3], 0x55);
+ xmm[2] = _mm_shuffle_ps (b[3], b[3], 0xaa);
+ xmm[3] = _mm_shuffle_ps (b[3], b[3], 0xff);
- for (y = 0; y < 4; ++y)
+ b[3] = _mm_load_ps(in2[3]); //finish loading matrix2, do not change b after this!
+/*
+ do
{
- a[y] = _mm_load_ps(in1[y]);
-
- //load rows as columns
- 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], b[0] );
xmm[1] = _mm_mul_ps( xmm[1], b[1] );
+ xmm[0] = _mm_add_ps( xmm[0], xmm[1] ); //done with xmm1
+
+ xmm[1] = _mm_load_ps(in1[y+1]); //load next row, shuffle this last
+
xmm[2] = _mm_mul_ps( xmm[2], b[2] );
xmm[3] = _mm_mul_ps( xmm[3], b[3] );
+ xmm[2] = _mm_add_ps( xmm[2], xmm[3] ); //done with xmm3
- xmm[0] = _mm_add_ps( xmm[0], xmm[1] );
- xmm[2] = _mm_add_ps( xmm[2], xmm[3] );
- a[y] = _mm_add_ps( xmm[0], xmm[2] );
- }
+ xmm[2] = _mm_add_ps( xmm[0], xmm[2] ); //final result
+ _mm_store_ps(out[y++], 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]);
+ xmm[3] = _mm_shuffle_ps (xmm[1], xmm[1], 0xff);
+ xmm[0] = _mm_shuffle_ps (xmm[1], xmm[1], 0x00);
+ xmm[2] = _mm_shuffle_ps (xmm[1], xmm[1], 0xaa);
+ xmm[1] = _mm_shuffle_ps (xmm[1], xmm[1], 0x55);
+ } while (y < 4);
+*/
+ //manually unroll loop, much faster!!
+ //loop 1
+ xmm[0] = _mm_mul_ps( xmm[0], b[0] );
+ xmm[1] = _mm_mul_ps( xmm[1], b[1] );
+ xmm[0] = _mm_add_ps( xmm[0], xmm[1] ); //done with xmm1
+
+ xmm[1] = _mm_load_ps(in1[1]); //load next row, shuffle this last
+
+ xmm[2] = _mm_mul_ps( xmm[2], b[2] );
+ xmm[3] = _mm_mul_ps( xmm[3], b[3] );
+ xmm[2] = _mm_add_ps( xmm[2], xmm[3] ); //done with xmm3
+
+ xmm[2] = _mm_add_ps( xmm[0], xmm[2] ); //final result
+ _mm_store_ps(out[0], xmm[2]);
+
+ xmm[3] = _mm_shuffle_ps (xmm[1], xmm[1], 0xff);
+ xmm[0] = _mm_shuffle_ps (xmm[1], xmm[1], 0x00);
+ xmm[2] = _mm_shuffle_ps (xmm[1], xmm[1], 0xaa);
+ xmm[1] = _mm_shuffle_ps (xmm[1], xmm[1], 0x55);
+
+ //loop2
+ xmm[0] = _mm_mul_ps( xmm[0], b[0] );
+ xmm[1] = _mm_mul_ps( xmm[1], b[1] );
+ xmm[0] = _mm_add_ps( xmm[0], xmm[1] ); //done with xmm1
+
+ xmm[1] = _mm_load_ps(in1[2]); //load next row, shuffle this last
+
+ xmm[2] = _mm_mul_ps( xmm[2], b[2] );
+ xmm[3] = _mm_mul_ps( xmm[3], b[3] );
+ xmm[2] = _mm_add_ps( xmm[2], xmm[3] ); //done with xmm3
+
+ xmm[2] = _mm_add_ps( xmm[0], xmm[2] ); //final result
+ _mm_store_ps(out[1], xmm[2]);
+
+ xmm[3] = _mm_shuffle_ps (xmm[1], xmm[1], 0xff);
+ xmm[0] = _mm_shuffle_ps (xmm[1], xmm[1], 0x00);
+ xmm[2] = _mm_shuffle_ps (xmm[1], xmm[1], 0xaa);
+ xmm[1] = _mm_shuffle_ps (xmm[1], xmm[1], 0x55);
+
+ //loop3
+ xmm[0] = _mm_mul_ps( xmm[0], b[0] );
+ xmm[1] = _mm_mul_ps( xmm[1], b[1] );
+ xmm[0] = _mm_add_ps( xmm[0], xmm[1] ); //done with xmm1
+
+ xmm[1] = _mm_load_ps(in1[3]); //load next row, shuffle this last
+
+ xmm[2] = _mm_mul_ps( xmm[2], b[2] );
+ xmm[3] = _mm_mul_ps( xmm[3], b[3] );
+ xmm[2] = _mm_add_ps( xmm[2], xmm[3] ); //done with xmm3
+
+ xmm[2] = _mm_add_ps( xmm[0], xmm[2] ); //final result
+ _mm_store_ps(out[2], xmm[2]);
+
+ xmm[3] = _mm_shuffle_ps (xmm[1], xmm[1], 0xff);
+ xmm[0] = _mm_shuffle_ps (xmm[1], xmm[1], 0x00);
+ xmm[2] = _mm_shuffle_ps (xmm[1], xmm[1], 0xaa);
+ xmm[1] = _mm_shuffle_ps (xmm[1], xmm[1], 0x55);
+
+ //loop4
+ xmm[0] = _mm_mul_ps( xmm[0], b[0] );
+ xmm[1] = _mm_mul_ps( xmm[1], b[1] );
+ xmm[0] = _mm_add_ps( xmm[0], xmm[1] ); //done with xmm1
+
+ xmm[2] = _mm_mul_ps( xmm[2], b[2] );
+ xmm[3] = _mm_mul_ps( xmm[3], b[3] );
+ xmm[2] = _mm_add_ps( xmm[2], xmm[3] ); //done with xmm3
+
+ xmm[2] = _mm_add_ps( xmm[0], xmm[2] ); //final result
+ _mm_store_ps(out[3], xmm[2]);
}
//This is an SSE matrix vector multiply, see the standard C++ code
@@ -321,6 +393,22 @@
}
*/
+void LoadIdentity(FloatRow* matrix)
+{
+ float *m = (float*)matrix;
+
+ __m128 r[2];
+
+ r[0] = _mm_set_ps(0.0f,0.0f,0.0f,1.0f);
+ _mm_storer_ps(m+12,r[0]); //reverse r[0]
+
+ r[1] = _mm_shuffle_ps(r[0], r[0], _MM_SHUFFLE(1,1,0,1));
+ _mm_storer_ps(m+8,r[1]); //reverse r[1]
+
+ _mm_store_ps(m, r[0]);
+ _mm_store_ps(m+4, r[1]);
+}
+
void MMCrossProduct( const FloatRow& r1, const FloatRow& r2, FloatRow& result)
{
__m128 a,b,c,d,r;//using more registers is faster
Modified: Mercury2/src/MercuryMath.h
===================================================================
--- Mercury2/src/MercuryMath.h 2010-05-17 23:58:27 UTC (rev 733)
+++ Mercury2/src/MercuryMath.h 2010-05-18 14:48:33 UTC (rev 734)
@@ -109,6 +109,7 @@
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 LoadIdentity(FloatRow* matrix);
//http://graphics.stanford.edu/~seander/bithacks.html
#define SetBit(x,mask,t) ((x & ~mask) | (-t & mask)) /*superscalar CPU version*/
Modified: Mercury2/src/MercuryMatrix.cpp
===================================================================
--- Mercury2/src/MercuryMatrix.cpp 2010-05-17 23:58:27 UTC (rev 733)
+++ Mercury2/src/MercuryMatrix.cpp 2010-05-18 14:48:33 UTC (rev 734)
@@ -126,9 +126,7 @@
void MercuryMatrix::LoadIdentity()
{
- 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;
+ ::LoadIdentity(m_matrix);
}
void MercuryMatrix::Translate(float x, float y, float z)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-17 23:58:33
|
Revision: 733
http://hgengine.svn.sourceforge.net/hgengine/?rev=733&view=rev
Author: axlecrusher
Date: 2010-05-17 23:58:27 +0000 (Mon, 17 May 2010)
Log Message:
-----------
Fix SSE on windows. We can't rely on the stack to align variables properly so we need to do it ourself.
Modified Paths:
--------------
Mercury2/src/AlignedBuffer.h
Mercury2/src/MercuryMath.cpp
Mercury2/src/MercuryMatrix.cpp
Mercury2/src/MercuryMatrix.h
Modified: Mercury2/src/AlignedBuffer.h
===================================================================
--- Mercury2/src/AlignedBuffer.h 2010-05-16 15:28:56 UTC (rev 732)
+++ Mercury2/src/AlignedBuffer.h 2010-05-17 23:58:27 UTC (rev 733)
@@ -18,7 +18,10 @@
void Allocate(unsigned long count, uint8_t alignment = 32)
{
- SAFE_FREE(m_mem);
+ if (m_mem!=0)
+ free(m_mem);
+ m_mem=0;
+
void * m_memret;
m_data = (T*)mmemalign(alignment, sizeof(T)*count, m_memret);
m_mem = (T*)m_memret;
@@ -27,7 +30,8 @@
void Free()
{
- SAFE_FREE(m_mem);
+ if (m_mem!=0)
+ free(m_mem);
m_data = NULL;
m_length = 0;
}
Modified: Mercury2/src/MercuryMath.cpp
===================================================================
--- Mercury2/src/MercuryMath.cpp 2010-05-16 15:28:56 UTC (rev 732)
+++ Mercury2/src/MercuryMath.cpp 2010-05-17 23:58:27 UTC (rev 733)
@@ -320,13 +320,15 @@
_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);
+ //unaligned load, vectors are not aligned
+ t1 = _mm_loadu_ps(r1);
+ t2 = _mm_loadu_ps(r2);
a = _mm_shuffle_ps(t1, t1, 0xc9);
b = _mm_shuffle_ps(t2, t2, 0xd2);
@@ -337,7 +339,7 @@
a = _mm_mul_ps( c, d );
r = _mm_sub_ps(r,a);
- _mm_store_ps(result, r);
+ _mm_storeu_ps(result, r);
}
#endif
Modified: Mercury2/src/MercuryMatrix.cpp
===================================================================
--- Mercury2/src/MercuryMatrix.cpp 2010-05-16 15:28:56 UTC (rev 732)
+++ Mercury2/src/MercuryMatrix.cpp 2010-05-17 23:58:27 UTC (rev 733)
@@ -1,6 +1,11 @@
#include "MercuryMatrix.h"
#include <MercuryLog.h>
+MercuryMatrixMemory::MercuryMatrixMemory()
+{
+ m_data.Allocate(rows,16);
+}
+
MercuryMatrixMemory& MercuryMatrixMemory::GetInstance()
{
static MercuryMatrixMemory* mmm = NULL;
@@ -19,7 +24,7 @@
MSemaphoreLock lock(&m_lock);
for (unsigned int i = 0; i < rows;i++)
- m_free.push_back( m_data+i );
+ m_free.push_back( m_data.Buffer()+i );
}
FloatRow* MercuryMatrixMemory::GetNewMatrix()
Modified: Mercury2/src/MercuryMatrix.h
===================================================================
--- Mercury2/src/MercuryMatrix.h 2010-05-16 15:28:56 UTC (rev 732)
+++ Mercury2/src/MercuryMatrix.h 2010-05-17 23:58:27 UTC (rev 733)
@@ -10,6 +10,8 @@
#include <list>
#include <MSemaphore.h>
+#include <AlignedBuffer.h>
+
///Memory holder for matrices
class MercuryMatrixMemory
{
@@ -17,15 +19,16 @@
to try to take advantage of data prefetching. Some matrix data should get a
free ride into the CPU cache. */
public:
+ MercuryMatrixMemory();
void Init();
static MercuryMatrixMemory& GetInstance();
FloatRow* GetNewMatrix();
void FreeMatrix(FloatRow* m);
private:
+ static const unsigned int rows = 1024; //1024 matrices * 64bytes each = 64kb
typedef FloatRow MatrixArray[4]; //64kb
- static const unsigned int rows = 1024; //1024 matrices * 64bytes each = 64kb
+ AlignedBuffer<MatrixArray> m_data;
std::list< MatrixArray* > m_free;
- MatrixArray m_data[rows];
MSemaphore m_lock;
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-16 15:29:02
|
Revision: 732
http://hgengine.svn.sourceforge.net/hgengine/?rev=732&view=rev
Author: axlecrusher
Date: 2010-05-16 15:28:56 +0000 (Sun, 16 May 2010)
Log Message:
-----------
Use indices to take advantave of degenerate triangles.
Modified Paths:
--------------
Mercury2/modules/ParticleEmitter.cpp
Mercury2/modules/ParticleEmitter.h
Modified: Mercury2/modules/ParticleEmitter.cpp
===================================================================
--- Mercury2/modules/ParticleEmitter.cpp 2010-05-06 07:11:07 UTC (rev 731)
+++ Mercury2/modules/ParticleEmitter.cpp 2010-05-16 15:28:56 UTC (rev 732)
@@ -13,13 +13,14 @@
#define BUFFER_OFFSET(i) ((char*)NULL + (i))
ParticleBase::ParticleBase()
- :m_age(0), m_lifespan(0), m_particleVobData(NULL)
+ :m_age(0), m_lifespan(0), m_particleVobData(NULL), m_particleIndexData(NULL)
{
}
ParticleBase::~ParticleBase()
{
m_particleVobData = NULL;
+ m_particleIndexData = NULL;
}
void ParticleBase::Init()
@@ -37,28 +38,28 @@
void ParticleBase::WriteAgeToVBO()
{
- m_emitter->SetDirtyVBO();
+ m_emitter->SetDirtyVertices();
for (uint8_t i = 0; i < 4; ++i)
WriteFloatToVertices(m_age,i,3);
}
void ParticleBase::WriteLifespanToVBO()
{
- m_emitter->SetDirtyVBO();
+ m_emitter->SetDirtyVertices();
for (uint8_t i = 0; i < 4; ++i)
WriteFloatToVertices(m_lifespan,i,4);
}
void ParticleBase::WriteRand1ToVBO()
{
- m_emitter->SetDirtyVBO();
+ m_emitter->SetDirtyVertices();
for (uint8_t i = 0; i < 4; ++i)
WriteFloatToVertices(m_rand1,i,5);
}
void ParticleBase::WriteRand2ToVBO()
{
- m_emitter->SetDirtyVBO();
+ m_emitter->SetDirtyVertices();
for (uint8_t i = 0; i < 4; ++i)
WriteFloatToVertices(m_rand2,i,6);
}
@@ -84,29 +85,18 @@
m_particleVobData[i++] = 0.5; m_particleVobData[i++] = 0.5; m_particleVobData[i++] = 0;
i+=4; m_particleVobData[i++] = 1; m_particleVobData[i++] = 1; //skip color data and set U,V
-/* for (uint8_t i = 0; i < 4; ++i)
- {
- WriteFloatToVertices(0,i,0);
- WriteFloatToVertices(0,i,1);
- WriteFloatToVertices(0,i,2);
- }
-*/
- m_emitter->SetDirtyVBO();
+ for (uint8_t i = 1; i < 4; ++i)
+ m_particleIndexData[i] = m_particleIndexData[0]+i; //reconstruct indices
+
+ m_emitter->SetDirtyVertices();
+ m_emitter->SetDirtyIndices();
}
void ParticleBase::Deactivate()
{
-// m_age = 0; //doing this breaks IsActive()
-// WriteAgeToVBO();
- for (uint8_t i = 0; i < 4; ++i)
- {
- //zero vertices should enable fast empty set culling but does not work might need FBO
- WriteFloatToVertices(0,i,0);
- WriteFloatToVertices(0,i,1);
- WriteFloatToVertices(0,i,2);
- WriteFloatToVertices(0,i,3); //fake zero age
- }
- m_emitter->SetDirtyVBO();
+ for (uint8_t i = 1; i < 4; ++i)
+ m_particleIndexData[i] = m_particleIndexData[0]; //degenerate triangle renders nothing
+ m_emitter->SetDirtyIndices();
}
void ParticleBase::WriteFloatToVertices(float v, uint8_t vertexIndex, uint8_t offset)
@@ -126,8 +116,9 @@
:base(), m_maxParticles(50), m_age(0), m_emitDelay(0.1), m_lifespan(0),
m_particlesEmitted(0), m_particleMinLife(0.1), m_particleMaxLife(5),
m_particles(NULL), GenerateParticlesClbk(NULL),
- m_bufferID(0), m_dirtyVBO(false)
+ m_dirtyVBO(0)
{
+ m_bufferID[0] = 0;
m_iForcePasses = m_iForcePasses | (1<<15);
m_iForcePasses = m_iForcePasses | (1<<7);
Init();
@@ -136,7 +127,7 @@
ParticleEmitter::~ParticleEmitter()
{
- if (m_bufferID > 0) { GLCALL( glDeleteBuffersARB(1, &m_bufferID) ); }
+ if (m_bufferID[0] > 0) { GLCALL( glDeleteBuffersARB(2, m_bufferID) ); }
SAFE_DELETE_ARRAY(m_particles); //do we need to destroy each element????
SAFE_DELETE(GenerateParticlesClbk);
@@ -231,6 +222,7 @@
m_maxParticles = count;
m_vertexData.Allocate(m_maxParticles*ParticleBase::STRIDE*4);
+ m_indexData.Allocate(m_maxParticles*4);
SAFE_DELETE_ARRAY(m_particles);
// if (GenerateParticlesClbk) m_particles = (*GenerateParticlesClbk)(m_maxParticles);
@@ -246,6 +238,8 @@
ParticleBase* p = m_particles+i;
p->m_emitter = this;
p->m_particleVobData = m_vertexData.Buffer()+(ParticleBase::STRIDE*4*i);
+ p->m_particleIndexData = m_indexData.Buffer() + (4*i);
+ p->m_particleIndexData[0]=p->m_particleIndexData[1]=p->m_particleIndexData[2]=p->m_particleIndexData[3]=i*4; //initial degenerate
p->Deactivate();
// printf("addr1 %p\n", p);
m_inactive.push_back( p );
@@ -263,22 +257,26 @@
GLCALL( glPushAttrib(GL_ENABLE_BIT|GL_CURRENT_BIT) );
GLCALL( glDisable(GL_CULL_FACE) );
- if (m_bufferID==0)
+ if (m_bufferID[0]==0)
{
- GLCALL( glGenBuffersARB(1, &m_bufferID) );
+ GLCALL( glGenBuffersARB(2, m_bufferID) );
}
- GLCALL( glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferID) );
+ GLCALL( glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferID[0]) );
+ GLCALL( glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_bufferID[1]) );
// GLCALL( glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0) );
MercuryVBO::SetLastRendered(this);
- if (m_dirtyVBO)
+ if (m_dirtyVBO&&0x1)
{
- m_dirtyVBO = false;
GLCALL( glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_vertexData.LengthInBytes(), m_vertexData.Buffer(), GL_STREAM_DRAW_ARB) );
}
-
+ if (m_dirtyVBO&&0x2)
+ {
+ GLCALL( glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_indexData.LengthInBytes(), m_indexData.Buffer(), GL_STREAM_DRAW_ARB) );
+ }
+ m_dirtyVBO = 0;
GLCALL( glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT) );
//do render stuff here
@@ -291,7 +289,9 @@
GLCALL( glVertexPointer(3, GL_FLOAT, ParticleBase::STRIDE*sizeof(float), BUFFER_OFFSET( 0*sizeof(float) ) ) );
GLCALL( glColorPointer(4, GL_FLOAT, ParticleBase::STRIDE*sizeof(float), BUFFER_OFFSET( 3*sizeof(float) ) ) );
- GLCALL( glDrawArrays(GL_QUADS, 0, m_maxParticles*4) );
+// GLCALL( glDrawArrays(GL_QUADS, 0, m_maxParticles*4) );
+// GLCALL( glDrawRangeElements( GL_QUADS, 0, m_maxParticles*4,m_maxParticles*4, GL_UNSIGNED_SHORT, NULL) );
+ GLCALL( glDrawElements(GL_QUADS,m_maxParticles*4,GL_UNSIGNED_SHORT,0) );
GLCALL( glPopClientAttrib() );
GLCALL( glPopAttrib() );
Modified: Mercury2/modules/ParticleEmitter.h
===================================================================
--- Mercury2/modules/ParticleEmitter.h 2010-05-06 07:11:07 UTC (rev 731)
+++ Mercury2/modules/ParticleEmitter.h 2010-05-16 15:28:56 UTC (rev 732)
@@ -43,6 +43,7 @@
ParticleEmitter* m_emitter;
// MercuryNode* m_particleGraph;
float* m_particleVobData; //pointer to position in VBO
+ uint16_t* m_particleIndexData; //pointer to position in index list
};
class ParticleEmitter : public MercuryNode
@@ -62,8 +63,10 @@
virtual void Render(const MercuryMatrix& matrix);
void SetMaxParticleCount(uint16_t count);
- inline void SetDirtyVBO() { m_dirtyVBO=true; }
+ inline void SetDirtyVertices() { m_dirtyVBO = m_dirtyVBO||0x1; }
+ inline void SetDirtyIndices() { m_dirtyVBO = m_dirtyVBO||0x2; }
+
static uint32_t ResetDrawnCount();
GENRTTI( ParticleEmitter );
@@ -87,9 +90,11 @@
Callback1R<uint32_t,ParticleBase*>* GenerateParticlesClbk;
AlignedBuffer<float> m_vertexData;
+ AlignedBuffer<uint16_t> m_indexData;
- unsigned int m_bufferID;
- bool m_dirtyVBO;
+ unsigned int m_bufferID[2];
+// bool m_dirtyVBO;
+ uint8_t m_dirtyVBO;
std::list< ParticleBase* > m_active, m_inactive;
// MercuryNode* m_masterParticle;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-05 11:04:23
|
Revision: 724
http://hgengine.svn.sourceforge.net/hgengine/?rev=724&view=rev
Author: axlecrusher
Date: 2010-05-05 11:04:17 +0000 (Wed, 05 May 2010)
Log Message:
-----------
Explicit call to destructor if using MercuryCTA. Fixes MercuryMatrix leak when IsHidden.
Modified Paths:
--------------
Mercury2/src/MercuryMessageManager.cpp
Mercury2/src/RenderGraph.cpp
Modified: Mercury2/src/MercuryMessageManager.cpp
===================================================================
--- Mercury2/src/MercuryMessageManager.cpp 2010-05-04 10:41:53 UTC (rev 723)
+++ Mercury2/src/MercuryMessageManager.cpp 2010-05-05 11:04:17 UTC (rev 724)
@@ -42,6 +42,7 @@
{
FireOffMessage( *mh );
SAFE_DELETE( mh->data );
+ mh->~MessageHolder();//explicitly call destructor since free() is used
HolderAllocator.Free(mh);
}
}
Modified: Mercury2/src/RenderGraph.cpp
===================================================================
--- Mercury2/src/RenderGraph.cpp 2010-05-04 10:41:53 UTC (rev 723)
+++ Mercury2/src/RenderGraph.cpp 2010-05-05 11:04:17 UTC (rev 724)
@@ -125,6 +125,7 @@
for (i = srs->Assets.begin();i != srs->Assets.end(); ++i)
(*i)->PostRender(srs->Node);
+ srs->~StoreRenderState();//explicitly call destructor since free() is used
AlphaHolderAllocator.Free( srs );
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-04 10:42:02
|
Revision: 723
http://hgengine.svn.sourceforge.net/hgengine/?rev=723&view=rev
Author: axlecrusher
Date: 2010-05-04 10:41:53 +0000 (Tue, 04 May 2010)
Log Message:
-----------
Change back to 1000ms and set l= each loop
Modified Paths:
--------------
Mercury2/src/MercuryThreads.h
Modified: Mercury2/src/MercuryThreads.h
===================================================================
--- Mercury2/src/MercuryThreads.h 2010-05-04 07:06:13 UTC (rev 722)
+++ Mercury2/src/MercuryThreads.h 2010-05-04 10:41:53 UTC (rev 723)
@@ -123,8 +123,8 @@
{
//loop until we get a lock but use a timeout so we are warned
//of a held mutex indicating a possible deadlock
- bool l = m_mutex->Wait(0xFFFFFF);
- while (!l) m_mutex->Wait(0xFFFFFF);
+ bool l = m_mutex->Wait(1000);
+ while (!l) l = m_mutex->Wait(1000);
}
~AutoMutexLock()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2010-05-04 07:06:19
|
Revision: 722
http://hgengine.svn.sourceforge.net/hgengine/?rev=722&view=rev
Author: cnlohr
Date: 2010-05-04 07:06:13 +0000 (Tue, 04 May 2010)
Log Message:
-----------
"fix" threads on Linux i686, or rather, avoid potentially problematic area
Modified Paths:
--------------
Mercury2/src/MercuryThreads.cpp
Mercury2/src/MercuryThreads.h
Modified: Mercury2/src/MercuryThreads.cpp
===================================================================
--- Mercury2/src/MercuryThreads.cpp 2010-05-03 02:28:59 UTC (rev 721)
+++ Mercury2/src/MercuryThreads.cpp 2010-05-04 07:06:13 UTC (rev 722)
@@ -9,6 +9,26 @@
#include <stdint.h>
#endif
+//#define EXTRA_DEBUG_ON_THREAD_FAIL
+
+#ifdef EXTRA_DEBUG_ON_THREAD_FAIL
+#include <MercuryBacktrace.h>
+void ThreadPrintBacktrace()
+{
+ fprintf( stderr, "Printing backtrace...\n" );
+ char buffer[2048];
+ int i = cnget_backtrace( 1, buffer, 2048 );
+ fprintf( stderr, "%s\n", buffer );
+}
+
+#else
+void ThreadPrintBacktrace()
+{
+}
+#endif
+
+
+
//XXX WARNING in windows mutex of the same name are shared!!!
//we can not give mutexes a default name
@@ -169,13 +189,22 @@
switch( r )
{
case WAIT_TIMEOUT:
+ //
+ ThreadPrintBacktrace();
+ //
fprintf(stderr, "Mutex held by thread ID 0x%x timed out (%d locks)\n", m_heldBy, iLockCount );
return false;
case WAIT_FAILED:
+ //
+ ThreadPrintBacktrace();
+ //
fprintf(stderr, "Mutex held by thread ID 0x%x failed (%d locks)\n", m_heldBy, iLockCount );
return false;
}
#else
+ //This seems to have some curious behavior in i386 Linux (tested and found problematic in Ubuntu 9.04)
+ //which can cause a crash of the program in an infinite loop. I do not know what is casuing it, but
+ //My general suggestion is that it be avoided - Charles
if ( lMilliseconds < 0xFFFFFF )
{
timeval t;
@@ -205,6 +234,7 @@
fprintf(stderr, "Max Recursive Locks Reached\n");
return false;
case ETIMEDOUT:
+ ThreadPrintBacktrace();
fprintf(stderr, "Mutex held by thread ID 0x%lx timed out (%d locks)\n", m_heldBy, iLockCount );
return false;
}
Modified: Mercury2/src/MercuryThreads.h
===================================================================
--- Mercury2/src/MercuryThreads.h 2010-05-03 02:28:59 UTC (rev 721)
+++ Mercury2/src/MercuryThreads.h 2010-05-04 07:06:13 UTC (rev 722)
@@ -123,8 +123,8 @@
{
//loop until we get a lock but use a timeout so we are warned
//of a held mutex indicating a possible deadlock
- bool l = m_mutex->Wait(1000);
- while (!l) m_mutex->Wait(1000);
+ bool l = m_mutex->Wait(0xFFFFFF);
+ while (!l) m_mutex->Wait(0xFFFFFF);
}
~AutoMutexLock()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-05-03 03:10:31
|
Revision: 719
http://hgengine.svn.sourceforge.net/hgengine/?rev=719&view=rev
Author: axlecrusher
Date: 2010-05-03 02:22:28 +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
Mercury2/src/MercuryMatrix.h
Modified: Mercury2/src/MercuryMatrix.cpp
===================================================================
--- Mercury2/src/MercuryMatrix.cpp 2010-05-03 02:11:54 UTC (rev 718)
+++ Mercury2/src/MercuryMatrix.cpp 2010-05-03 02:22:28 UTC (rev 719)
@@ -129,10 +129,12 @@
void MercuryMatrix::Translate(float x, float y, float z)
{
MercuryMatrix m;
+
m[0][3] = x;
m[1][3] = y;
m[2][3] = z;
- *this *= m;
+
+ MatrixMultiply4f(m_matrix,m.m_matrix,m_matrix);
}
void MercuryMatrix::RotateXYZ(float x, float y, float z)
@@ -172,7 +174,7 @@
matrix[2][3] = 0;
matrix[3][3] = 1;
- *this *= matrix;
+ MatrixMultiply4f(m_matrix,matrix.m_matrix,m_matrix);
}
void MercuryMatrix::RotateAngAxis( float fAngle, float ix, float iy, float iz )
@@ -249,7 +251,7 @@
matrix[2][3] = tZ;
matrix[3][3] = 1;
- *this *= matrix;
+ MatrixMultiply4f(m_matrix,matrix.m_matrix,m_matrix);
}
@@ -271,12 +273,6 @@
return r;
}
-MercuryMatrix& MercuryMatrix::operator*=(const MercuryMatrix& m)
-{
- MatrixMultiply4f ( m_matrix, m.m_matrix, m_matrix);
- return *this;
-}
-
void MercuryMatrix::Print() const
{
for (int i = 0; i < 4; ++i)
Modified: Mercury2/src/MercuryMatrix.h
===================================================================
--- Mercury2/src/MercuryMatrix.h 2010-05-03 02:11:54 UTC (rev 718)
+++ Mercury2/src/MercuryMatrix.h 2010-05-03 02:22:28 UTC (rev 719)
@@ -52,8 +52,10 @@
inline const float* Ptr() const { return (const float*)m_matrix; }
MercuryMatrix operator*(const MercuryMatrix& m) const;
- MercuryMatrix& operator*=(const MercuryMatrix& m);
+ inline MercuryMatrix& operator*=(const MercuryMatrix& m)
+ { MatrixMultiply4f ( m_matrix, m.m_matrix, m_matrix); return *this; }
+
MercuryVector operator*(const MercuryVertex& v) const;
void Translate(float x, float y, float z);
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:29:05
|
Revision: 721
http://hgengine.svn.sourceforge.net/hgengine/?rev=721&view=rev
Author: axlecrusher
Date: 2010-05-03 02:28:59 +0000 (Mon, 03 May 2010)
Log Message:
-----------
Use FloatRow. There is no reason not to now that its just an aligned float array.
Modified Paths:
--------------
Mercury2/src/MQuaternion.h
Modified: Mercury2/src/MQuaternion.h
===================================================================
--- Mercury2/src/MQuaternion.h 2010-05-03 02:25:54 UTC (rev 720)
+++ Mercury2/src/MQuaternion.h 2010-05-03 02:28:59 UTC (rev 721)
@@ -80,7 +80,9 @@
//Tricky: This cannot be a float row, otherwise all references cease to operate as one would expect.
//Also, for most operations, it appeared to go slower. All the moving in and out of these variables
//is disadvantagious.
- float m_wxyz[4];
+// float m_wxyz[4];
+ //FlotRow is not just 16 byte alligned float[4] array. Ok now.
+ FloatRow m_wxyz;
} CC_ALIGN(16);
///Produce a matrix out of a rotation x, then y then z (how Mercury does it)
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:26:00
|
Revision: 720
http://hgengine.svn.sourceforge.net/hgengine/?rev=720&view=rev
Author: axlecrusher
Date: 2010-05-03 02:25:54 +0000 (Mon, 03 May 2010)
Log Message:
-----------
It is not necessary to look up the uniform by name again when we just found it and can just pass the uniform location along.
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Mercury2/src/Shader.h
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2010-05-03 02:22:28 UTC (rev 719)
+++ Mercury2/src/Shader.cpp 2010-05-03 02:25:54 UTC (rev 720)
@@ -442,7 +442,7 @@
{
ShaderAttribute* a = m_globalAttributes.get( ui->name );
if( a )
- SetAttributeInternal(ui->name,*a);
+ SetAttributeInternal(ui->id,*a);
}
}
@@ -479,26 +479,30 @@
void Shader::SetAttributeInternal(const MString& name, const ShaderAttribute& x)
{
int location = GetUniformLocation( name );
+ SetAttributeInternal(location, x);
+}
- if ( location != -1 )
+void Shader::SetAttributeInternal(int uniformLoc, const ShaderAttribute& x)
+{
+ if ( uniformLoc != -1 )
{
switch( x.type )
{
case ShaderAttribute::TYPE_INT:
case ShaderAttribute::TYPE_SAMPLER:
- GLCALL( glUniform1iARB( location, x.value.iInt ) );
+ GLCALL( glUniform1iARB( uniformLoc, x.value.iInt ) );
break;
case ShaderAttribute::TYPE_FLOAT:
- GLCALL( glUniform1fARB( location, x.value.fFloat ) );
+ GLCALL( glUniform1fARB( uniformLoc, x.value.fFloat ) );
break;
case ShaderAttribute::TYPE_FLOATV4:
- GLCALL( glUniform4fvARB( location, 1, &x.value.fFloatV4[0] ) );
+ GLCALL( glUniform4fvARB( uniformLoc, 1, &x.value.fFloatV4[0] ) );
break;
case ShaderAttribute::TYPE_MATRIX:
- GLCALL( glUniformMatrix4fvARB(location, 1, 1, x.value.matrix) ); //transpose too
+ GLCALL( glUniformMatrix4fvARB(uniformLoc, 1, 1, x.value.matrix) ); //transpose too
break;
case ShaderAttribute::TYPE_INT4:
- GLCALL( glUniform4ivARB( location, 1, x.value.iInts ) );
+ GLCALL( glUniform4ivARB( uniformLoc, 1, x.value.iInts ) );
break;
};
GLERRORCHECK;
Modified: Mercury2/src/Shader.h
===================================================================
--- Mercury2/src/Shader.h 2010-05-03 02:22:28 UTC (rev 719)
+++ Mercury2/src/Shader.h 2010-05-03 02:25:54 UTC (rev 720)
@@ -100,6 +100,7 @@
int32_t GetUniformLocation(const MString& n);
void SetAttributeInternal(const MString& name, const ShaderAttribute& x);
+ void SetAttributeInternal(int uniformLoc, const ShaderAttribute& x);
///Suggested function for loading shaders.
/** This function looks for {sShaderName}.vert and {sShaderName}.frag. It will
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|