You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(46) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(185) |
Feb
(242) |
Mar
(237) |
Apr
(180) |
May
(102) |
Jun
(278) |
Jul
(114) |
Aug
(92) |
Sep
(246) |
Oct
(212) |
Nov
(279) |
Dec
(99) |
| 2007 |
Jan
(130) |
Feb
(194) |
Mar
(22) |
Apr
(72) |
May
(40) |
Jun
(111) |
Jul
(114) |
Aug
(154) |
Sep
(114) |
Oct
(2) |
Nov
(1) |
Dec
(5) |
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(6) |
Oct
(51) |
Nov
(34) |
Dec
(130) |
| 2009 |
Jan
(22) |
Feb
(20) |
Mar
(41) |
Apr
(45) |
May
(82) |
Jun
(96) |
Jul
(48) |
Aug
(90) |
Sep
(13) |
Oct
(49) |
Nov
(31) |
Dec
(21) |
| 2010 |
Jan
(25) |
Feb
(9) |
Mar
(7) |
Apr
(28) |
May
(27) |
Jun
(7) |
Jul
(1) |
Aug
|
Sep
(1) |
Oct
(1) |
Nov
(13) |
Dec
(2) |
| 2013 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <axl...@us...> - 2010-01-17 02:32:31
|
Revision: 668
http://hgengine.svn.sourceforge.net/hgengine/?rev=668&view=rev
Author: axlecrusher
Date: 2010-01-17 02:32:13 +0000 (Sun, 17 Jan 2010)
Log Message:
-----------
build vertex from 3 and 4 float arrays
Modified Paths:
--------------
Mercury2/src/MercuryValue.cpp
Mercury2/src/MercuryVertex.cpp
Modified: Mercury2/src/MercuryValue.cpp
===================================================================
--- Mercury2/src/MercuryValue.cpp 2010-01-17 02:26:59 UTC (rev 667)
+++ Mercury2/src/MercuryValue.cpp 2010-01-17 02:32:13 UTC (rev 668)
@@ -4,7 +4,7 @@
DelegateNotifierList::DelegateNotifierList( DeletionNotifier nf, MessageHandler * no ) :
- NotifyFunction( nf ), NotifyObject( no ), Next( 0 )
+ NotifyFunction( nf ), NotifyObject( no ), Next( NULL )
{
}
@@ -43,14 +43,14 @@
-MValue::MValue( ) : m_References( 0 ), m_CurType( TYPE_UNDEF ), DLDelete( 0 ), DLModify( 0 )
+MValue::MValue( ) : m_References( NULL ), m_CurType( TYPE_UNDEF ), DLDelete( NULL ), DLModify( NULL )
{
- m_Data.v = 0;
+ m_Data.v = NULL;
}
-MValue::MValue( MVType t ) : m_References( 0 ), m_CurType( t ), DLDelete( 0 ), DLModify( 0 )
+MValue::MValue( MVType t ) : m_References( NULL ), m_CurType( t ), DLDelete( NULL ), DLModify( NULL )
{
- m_Data.v = 0;
+ m_Data.v = NULL;
}
MValue::~MValue()
Modified: Mercury2/src/MercuryVertex.cpp
===================================================================
--- Mercury2/src/MercuryVertex.cpp 2010-01-17 02:26:59 UTC (rev 667)
+++ Mercury2/src/MercuryVertex.cpp 2010-01-17 02:32:13 UTC (rev 668)
@@ -19,10 +19,17 @@
(*this)[3] = iw;
}
-MercuryVertex::MercuryVertex( const float * in )
+MercuryVertex::MercuryVertex( const float* in3f, float f )
{
+ for (unsigned int i = 0; i < 3; ++i)
+ (*this)[i] = in3f[i];
+ (*this)[3] = f;
+}
+
+MercuryVertex::MercuryVertex( const float* in4f )
+{
for (unsigned int i = 0; i < 4; ++i)
- (*this)[i] = in[i];
+ (*this)[i] = in4f[i];
}
MercuryVertex::MercuryVertex( const MercuryVertex& v)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-01-17 02:27:05
|
Revision: 667
http://hgengine.svn.sourceforge.net/hgengine/?rev=667&view=rev
Author: axlecrusher
Date: 2010-01-17 02:26:59 +0000 (Sun, 17 Jan 2010)
Log Message:
-----------
copy constructor
Modified Paths:
--------------
Mercury2/src/DataTypes/MTriangle.cpp
Mercury2/src/DataTypes/MTriangle.h
Modified: Mercury2/src/DataTypes/MTriangle.cpp
===================================================================
--- Mercury2/src/DataTypes/MTriangle.cpp 2010-01-17 02:20:17 UTC (rev 666)
+++ Mercury2/src/DataTypes/MTriangle.cpp 2010-01-17 02:26:59 UTC (rev 667)
@@ -9,8 +9,16 @@
m_verts[2] = 0;
}
-MTriangle::MTriangle(const MercuryVertex a, const MercuryVertex& b, const MercuryVertex& c)
+MTriangle::MTriangle(const MTriangle& t)
{
+ m_verts[0] = t.m_verts[0];
+ m_verts[1] = t.m_verts[1];
+ m_verts[2] = t.m_verts[2];
+
+}
+
+MTriangle::MTriangle(const MercuryVertex& a, const MercuryVertex& b, const MercuryVertex& c)
+{
m_verts[0] = a;
m_verts[1] = b;
m_verts[2] = c;
Modified: Mercury2/src/DataTypes/MTriangle.h
===================================================================
--- Mercury2/src/DataTypes/MTriangle.h 2010-01-17 02:20:17 UTC (rev 666)
+++ Mercury2/src/DataTypes/MTriangle.h 2010-01-17 02:26:59 UTC (rev 667)
@@ -7,7 +7,8 @@
{
public:
MTriangle();
- MTriangle(const MercuryVertex a, const MercuryVertex& b, const MercuryVertex& c);
+ MTriangle(const MTriangle& t);
+ MTriangle(const MercuryVertex& a, const MercuryVertex& b, const MercuryVertex& c);
MercuryVertex Barycentric(const MercuryVertex& p);
bool IsInTriangle( const MercuryVertex& p );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-01-17 02:20:31
|
Revision: 666
http://hgengine.svn.sourceforge.net/hgengine/?rev=666&view=rev
Author: axlecrusher
Date: 2010-01-17 02:20:17 +0000 (Sun, 17 Jan 2010)
Log Message:
-----------
clean up how mutex works
fix unnecessary unlock after creating mutex
add proper mutex lock timeout for pthreads
Modified Paths:
--------------
Mercury2/src/MercuryThreads.cpp
Modified: Mercury2/src/MercuryThreads.cpp
===================================================================
--- Mercury2/src/MercuryThreads.cpp 2010-01-15 23:15:24 UTC (rev 665)
+++ Mercury2/src/MercuryThreads.cpp 2010-01-17 02:20:17 UTC (rev 666)
@@ -4,12 +4,15 @@
#include <windows.h>
#else
#include <errno.h>
+#include <time.h>
+#include <sys/time.h>
#endif
//XXX WARNING in windows mutex of the same name are shared!!!
//we can not give mutexes a default name
#include <stdio.h>
+#include <stdint.h>
MercuryThread::MercuryThread()
:m_haltOnDestroy(true), m_thread(0)
@@ -136,19 +139,15 @@
//Mutex functions
MercuryMutex::MercuryMutex( )
-:m_heldBy(0)
+:iLockCount(0),m_heldBy(0)
{
- iLockCount = 0;
Open( );
- UnLock();
}
MercuryMutex::MercuryMutex( const MString &name )
-:m_name(name),m_heldBy(0)
+:m_name(name),iLockCount(0),m_heldBy(0)
{
- iLockCount = 0;
Open( );
- UnLock();
}
MercuryMutex::~MercuryMutex( )
@@ -177,31 +176,39 @@
return false;
}
#else
-/* timespec abstime;
- abstime.tv_sec = 0;
- abstime.tv_nsec = lMilliseconds;
+ if ( lMilliseconds < 0xFFFFFF )
+ {
+ timeval t;
+ gettimeofday( &t, 0 ); //XXX I question the efficiency of this call -- Josh
+ uint64_t ns = t.tv_sec*1000000000 + t.tv_usec*1000 + lMilliseconds*1000000;
+
+ timespec timeout;
+ timeout.tv_sec = ns/1000000000;
+ timeout.tv_nsec = ns%1000000000;
+
+ r = pthread_mutex_timedlock( &m_mutex, &timeout );
+ }
+ else
+ {
+ r = pthread_mutex_lock( &m_mutex );
+ }
- pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
-
- pthread_cond_timedwait( &cond, &m_mutex, &abstime ); */
-// if (pthread_mutex_trylock( &m_mutex ) != 0)
-// {
-// printf("%s waiting\n", m_name.c_str());
- r = pthread_mutex_lock( &m_mutex );
- switch (r)
- {
- case EBUSY:
- fprintf(stderr, "Mutex held by thread ID 0x%x failed (%d locks)\n", m_heldBy, iLockCount );
- return false;
- case EINVAL:
- fprintf(stderr, "Invalid Mutex\n");
- return true;
- case EAGAIN:
- fprintf(stderr, "Max Recursive Locks Reached\n");
- return false;
- }
-// printf("%s locked\n", m_name.c_str());
-// }
+ switch (r)
+ {
+ case EBUSY:
+ fprintf(stderr, "Mutex held by thread ID 0x%lx failed (%d locks)\n", m_heldBy, iLockCount );
+ return false;
+ case EINVAL:
+ fprintf(stderr, "Invalid mutex or invalid timeout length %ldms\n", lMilliseconds );
+ return true;
+ case EAGAIN:
+ fprintf(stderr, "Max Recursive Locks Reached\n");
+ return false;
+ case ETIMEDOUT:
+ fprintf(stderr, "Mutex held by thread ID 0x%lx timed out (%d locks)\n", m_heldBy, iLockCount );
+ return false;
+ }
+// printf("%s locked\n", m_name.c_str());
#endif
// printf("Locked %s\n", m_name.c_str());
m_heldBy = MercuryThread::Current();
@@ -229,7 +236,6 @@
int MercuryMutex::Open( )
{
- ++iLockCount;
#if defined( WIN32 )
SECURITY_ATTRIBUTES *p = ( SECURITY_ATTRIBUTES* ) malloc( sizeof( SECURITY_ATTRIBUTES ) );
p->nLength = sizeof( SECURITY_ATTRIBUTES );
@@ -240,12 +246,16 @@
else
m_mutex = CreateMutex( p, true, (LPCWSTR)m_name.c_str() );
free( p );
+ ReleaseMutex( m_mutex ); //windows API locks mutex on creation
return (int)m_mutex;
#else
pthread_mutexattr_t attr;
pthread_mutexattr_init( &attr );
pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_RECURSIVE );
pthread_mutex_init( &m_mutex, &attr );
+
+//pthread_mutex_lock( &m_mutex ); //test deadlock
+
return 0;
#endif
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-01-15 23:15:30
|
Revision: 665
http://hgengine.svn.sourceforge.net/hgengine/?rev=665&view=rev
Author: axlecrusher
Date: 2010-01-15 23:15:24 +0000 (Fri, 15 Jan 2010)
Log Message:
-----------
updates for linux
Modified Paths:
--------------
Mercury2/src/MercuryThreads.cpp
Mercury2/src/ModuleManager.cpp
Modified: Mercury2/src/MercuryThreads.cpp
===================================================================
--- Mercury2/src/MercuryThreads.cpp 2010-01-15 21:55:57 UTC (rev 664)
+++ Mercury2/src/MercuryThreads.cpp 2010-01-15 23:15:24 UTC (rev 665)
@@ -2,6 +2,8 @@
#if defined( WIN32 )
#include <windows.h>
+#else
+#include <errno.h>
#endif
//XXX WARNING in windows mutex of the same name are shared!!!
@@ -185,7 +187,19 @@
// if (pthread_mutex_trylock( &m_mutex ) != 0)
// {
// printf("%s waiting\n", m_name.c_str());
- pthread_mutex_lock( &m_mutex );
+ r = pthread_mutex_lock( &m_mutex );
+ switch (r)
+ {
+ case EBUSY:
+ fprintf(stderr, "Mutex held by thread ID 0x%x failed (%d locks)\n", m_heldBy, iLockCount );
+ return false;
+ case EINVAL:
+ fprintf(stderr, "Invalid Mutex\n");
+ return true;
+ case EAGAIN:
+ fprintf(stderr, "Max Recursive Locks Reached\n");
+ return false;
+ }
// printf("%s locked\n", m_name.c_str());
// }
#endif
@@ -201,14 +215,16 @@
// printf("Unlocked %s\n", m_name.c_str());
--iLockCount;
if (iLockCount==0) m_heldBy = 0;
+
+ int r, error;
#if defined( WIN32 )
- bool r = ReleaseMutex( m_mutex )!=0;
- if (!r) fprintf(stderr, "Failed to release mutex %s, error %d!!\n", m_name.c_str(), GetLastError());
- return r;
+ r = ReleaseMutex( m_mutex );
+ if (r!=0) error = GetLastError();
#else
- pthread_mutex_unlock( &m_mutex );
- return true;
+ error = r = pthread_mutex_unlock( &m_mutex );
#endif
+ if (r!=0) fprintf(stderr, "Failed to release mutex %s, error %d!!\n", m_name.c_str(), error);
+ return r!=0;
}
int MercuryMutex::Open( )
Modified: Mercury2/src/ModuleManager.cpp
===================================================================
--- Mercury2/src/ModuleManager.cpp 2010-01-15 21:55:57 UTC (rev 664)
+++ Mercury2/src/ModuleManager.cpp 2010-01-15 23:15:24 UTC (rev 665)
@@ -120,7 +120,7 @@
void ModuleManager::ReloadModule( const MString & sClass )
{
- m_mHandleMutex.Wait();
+ AutoMutexLock lock(m_mHandleMutex);
std::set< void * > & s = m_hAllInstances[sClass];
std::set< void * >::iterator i = s.begin();
@@ -129,8 +129,6 @@
for( ; i != s.end(); i++ )
*((void**)(*i)) = newvtable;
-
- m_mHandleMutex.UnLock();
}
void ModuleManager::RegisterInstance( void * instance, const char * sClass )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-01-15 21:56:03
|
Revision: 664
http://hgengine.svn.sourceforge.net/hgengine/?rev=664&view=rev
Author: axlecrusher
Date: 2010-01-15 21:55:57 +0000 (Fri, 15 Jan 2010)
Log Message:
-----------
fix warnings
Modified Paths:
--------------
Mercury2/src/BoundingBox.cpp
Mercury2/src/Camera.cpp
Mercury2/src/DataStructures/SpatialHash.h
Mercury2/src/DataTypes/MTriangle.cpp
Mercury2/src/DataTypes/MTriangle.h
Mercury2/src/MercuryVBO.h
Modified: Mercury2/src/BoundingBox.cpp
===================================================================
--- Mercury2/src/BoundingBox.cpp 2010-01-15 21:53:59 UTC (rev 663)
+++ Mercury2/src/BoundingBox.cpp 2010-01-15 21:55:57 UTC (rev 664)
@@ -22,7 +22,7 @@
uint32_t OcclusionResult::GetSamples() const
{
- if (m_occlusionQuery == 0) return ~0;
+ if (m_occlusionQuery == 0) return ~(uint32_t(0));
uint32_t samples;
GLCALL( glGetQueryObjectuivARB(m_occlusionQuery, GL_QUERY_RESULT_ARB, &samples) );
Modified: Mercury2/src/Camera.cpp
===================================================================
--- Mercury2/src/Camera.cpp 2010-01-15 21:53:59 UTC (rev 663)
+++ Mercury2/src/Camera.cpp 2010-01-15 21:55:57 UTC (rev 664)
@@ -155,7 +155,7 @@
{
TransformNode::LoadFromXML( node );
m_origionalPosition = GetPosition();
- POST_MESSAGE("QueryTerrainPoint", new VertexDataMessage(GetPosition()), 0.00001);
+ POST_MESSAGE("QueryTerrainPoint", new VertexDataMessage(GetPosition()), 0.00001f);
}
Modified: Mercury2/src/DataStructures/SpatialHash.h
===================================================================
--- Mercury2/src/DataStructures/SpatialHash.h 2010-01-15 21:53:59 UTC (rev 663)
+++ Mercury2/src/DataStructures/SpatialHash.h 2010-01-15 21:55:57 UTC (rev 664)
@@ -46,8 +46,13 @@
//check for and skip duplicate
std::list<T>& cell = m_hashTable[ Index( ix, iy, iz ) ];
+
typename std::list<T>::iterator i = cell.begin();
- for (;i != cell.end(); ++i) if (*i == d) return;
+ for (;i != cell.end(); ++i)
+ {
+ const T& a = *i;
+ if (a == d) return;
+ }
cell.push_back( d );
// printf("added at %d %d %d\n", ix, iy, iz);
@@ -107,7 +112,7 @@
}
std::list<T>* m_hashTable;
- uint32_t m_spacing;
+ float m_spacing;
uint32_t m_cellCount;
};
Modified: Mercury2/src/DataTypes/MTriangle.cpp
===================================================================
--- Mercury2/src/DataTypes/MTriangle.cpp 2010-01-15 21:53:59 UTC (rev 663)
+++ Mercury2/src/DataTypes/MTriangle.cpp 2010-01-15 21:55:57 UTC (rev 664)
@@ -73,7 +73,7 @@
return r.Length() * 0.5;
}
-bool MTriangle::operator == (const MTriangle& rhs)
+bool MTriangle::operator == (const MTriangle& rhs) const
{
if (m_verts[0] != rhs.m_verts[0]) return false;
if (m_verts[1] != rhs.m_verts[1]) return false;
Modified: Mercury2/src/DataTypes/MTriangle.h
===================================================================
--- Mercury2/src/DataTypes/MTriangle.h 2010-01-15 21:53:59 UTC (rev 663)
+++ Mercury2/src/DataTypes/MTriangle.h 2010-01-15 21:55:57 UTC (rev 664)
@@ -15,7 +15,7 @@
float Area();
MercuryVertex InterpolatePosition(const MercuryVertex& barycentric);
- bool operator == (const MTriangle& rhs);
+ bool operator == (const MTriangle& rhs) const;
// private:
MercuryVertex m_verts[3];
Modified: Mercury2/src/MercuryVBO.h
===================================================================
--- Mercury2/src/MercuryVBO.h 2010-01-15 21:53:59 UTC (rev 663)
+++ Mercury2/src/MercuryVBO.h 2010-01-15 21:55:57 UTC (rev 664)
@@ -34,7 +34,7 @@
const short unsigned int* GetIndexHandle() const { return m_indexData.Buffer(); }
short unsigned int* GetIndexHandle() { return m_indexData.Buffer(); }
- inline uint16_t IndiceCount() const { return m_indexData.Length(); }
+ inline uint16_t IndiceCount() const { return (uint16_t)m_indexData.Length(); }
inline void DirtyVertices() { m_bDirtyVertices = true; }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-01-15 21:54:07
|
Revision: 663
http://hgengine.svn.sourceforge.net/hgengine/?rev=663&view=rev
Author: axlecrusher
Date: 2010-01-15 21:53:59 +0000 (Fri, 15 Jan 2010)
Log Message:
-----------
add more debugging options
Modified Paths:
--------------
Mercury2/src/Mercury2.cpp
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2010-01-15 21:52:17 UTC (rev 662)
+++ Mercury2/src/Mercury2.cpp 2010-01-15 21:53:59 UTC (rev 663)
@@ -21,6 +21,13 @@
#include <MercuryLog.h>
+#ifdef WIN32DBGMEM
+#define _CRTDBG_MAP_ALLOC
+#include <stdlib.h>
+#include <crtdbg.h>
+#endif
+
+
#define MULTIPASS
bool SHOWBOUNDINGVOLUME = false;
@@ -42,9 +49,9 @@
{
char buffer[2048];
LOG.Write(ssprintf( "Fatal error encountered in Mercury 2: %s", cn_get_crash_description( signal ) ));
- cnget_backtrace( 1, buffer, 2047 );
-
- //XXX: Sometimes we produce a crash, we get the crash report, and the next line doesn't work... This should be examined.
+ cnget_backtrace( 1, buffer, 2047 );
+
+ //XXX: Sometimes we produce a crash, we get the crash report, and the next line doesn't work... This should be examined.
LOG.Write( buffer );
return 0; //Continue regular crash.
@@ -95,15 +102,20 @@
int main( int argc, char** argv)
{
+#ifdef WIN32DBGMEM
+ _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
+#endif
unsigned long m_count = 0;
g_SceneGraphToLoad = "FILE:scenegraph.xml";
+#ifndef NOCRAHSHANDLE
cnset_execute_on_crash( SignalHandler );
+#endif
HandleCommandLineParameters( argc, argv );
-
- //Sound first.
- SOUNDMAN->Init( "" );
+
+ //Sound first.
+ SOUNDMAN->Init( "" );
MercuryWindow* w = MercuryWindow::MakeWindow();
#ifdef WIN32
@@ -168,19 +180,19 @@
float batches = MercuryVBO::ResetBatchCount()/(float)m_count;
float VBinds = MercuryVBO::ResetBindCount()/(float)m_count;
float Tbinds = Texture::ReadAndResetBindCount()/(float)m_count;
- LOG.Write( ssprintf("FPS: %f, VBO batches %f, TBinds %f, VBinds %f", m_count/fpsTimer.Age(), batches, Tbinds, VBinds) );
+ LOG.Write( ssprintf("FPS: %f, VBO batches %f, TBinds %f, VBinds %f", m_count/fpsTimer.Age(), batches, Tbinds, VBinds) );
#ifdef GL_PROFILE
float GLcalls = GLCALLCOUNT/(float)m_count;
GLCALLCOUNT = 0;
- LOG.Write( ssprintf("GL/f: %f", GLcalls) );
+ LOG.Write( ssprintf("GL/f: %f", GLcalls) );
#endif
m_count = 0;
fpsTimer = timer;
- }
-
-//Uncomment to enable scenegraph saving.
-// MString st;
-// root->SaveToXML( st );
+ }
+
+//Uncomment to enable scenegraph saving.
+// MString st;
+// root->SaveToXML( st );
// StringToFile( "test.xml", st );
}
while ( w->PumpMessages() );
@@ -199,30 +211,30 @@
// printf("Render wait %%%f\n", (RenderWaited/double(totalWaited))*100.0f);
return 0;
-}
-
-
-
-
-
-///XXXXXXXX STUB CODE XXXXXXXXXXX THIS CODE SHOULD BE REMOVED AS SOON AS TESTING OF THE VARIABLE SYSTEM IS COMPLETE
-class TestMouse
-{
-public:
- TestMouse()
- {
- MESSAGEMAN.GetValue( "TestMode" )->AttachModifyDelegate( (ValueDelegate)&TestMouse::ChangeX, (MessageHandler*)this );
- }
-
- void ChangeX( MValue * v )
- {
- printf( "Changed: %s\n", v->GetString().c_str() );
- }
-} TM;
-///XXXXXXX REMOVE THIS CODE BEFORE ANY RELEASE XXXXXXXXXXx
-
+}
+
+
+
+///XXXXXXXX STUB CODE XXXXXXXXXXX THIS CODE SHOULD BE REMOVED AS SOON AS TESTING OF THE VARIABLE SYSTEM IS COMPLETE
+class TestMouse
+{
+public:
+ TestMouse()
+ {
+ MESSAGEMAN.GetValue( "TestMode" )->AttachModifyDelegate( (ValueDelegate)&TestMouse::ChangeX, (MessageHandler*)this );
+ }
+
+ void ChangeX( MValue * v )
+ {
+ printf( "Changed: %s\n", v->GetString().c_str() );
+ }
+} TM;
+///XXXXXXX REMOVE THIS CODE BEFORE ANY RELEASE XXXXXXXXXXx
+
+
+
/* Copyright (c) 2008, Joshua Allen
* All rights reserved.
*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-01-15 21:52:24
|
Revision: 662
http://hgengine.svn.sourceforge.net/hgengine/?rev=662&view=rev
Author: axlecrusher
Date: 2010-01-15 21:52:17 +0000 (Fri, 15 Jan 2010)
Log Message:
-----------
add replace routine
Modified Paths:
--------------
Mercury2/src/MercuryString.cpp
Mercury2/src/MercuryString.h
Modified: Mercury2/src/MercuryString.cpp
===================================================================
--- Mercury2/src/MercuryString.cpp 2010-01-15 18:58:16 UTC (rev 661)
+++ Mercury2/src/MercuryString.cpp 2010-01-15 21:52:17 UTC (rev 662)
@@ -336,6 +336,17 @@
return strncmp( m_sCur + start, cmp, len );
}
+MString MString::replace(const MString& old, const MString& n)
+{
+ if (this->empty() || old.empty() || n.empty()) return *this;
+
+ int i = this->find(old);
+ if (i<0) return *this;
+
+ MString s = this->substr(0,i) + n + this->substr(i+old.length());
+ return s.replace(old, n);
+}
+
unsigned int MString::hash() const
{
unsigned int ret = 0;
Modified: Mercury2/src/MercuryString.h
===================================================================
--- Mercury2/src/MercuryString.h 2010-01-15 18:58:16 UTC (rev 661)
+++ Mercury2/src/MercuryString.h 2010-01-15 21:52:17 UTC (rev 662)
@@ -65,6 +65,8 @@
int compare( int start, int len, const MString & cmp ) const;
int compare( int start, int len, const char * cmp ) const;
+ MString replace(const MString& old, const MString& n);
+
unsigned int hash() const;
enum
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-01-15 18:58:33
|
Revision: 661
http://hgengine.svn.sourceforge.net/hgengine/?rev=661&view=rev
Author: axlecrusher
Date: 2010-01-15 18:58:16 +0000 (Fri, 15 Jan 2010)
Log Message:
-----------
fix CreateFile error checking
Modified Paths:
--------------
Mercury2/src/MercuryFileDriverDirect.cpp
Modified: Mercury2/src/MercuryFileDriverDirect.cpp
===================================================================
--- Mercury2/src/MercuryFileDriverDirect.cpp 2010-01-15 18:11:44 UTC (rev 660)
+++ Mercury2/src/MercuryFileDriverDirect.cpp 2010-01-15 18:58:16 UTC (rev 661)
@@ -168,8 +168,9 @@
#if defined(WIN32)
HANDLE hFile = CreateFile( (LPCWSTR)(m_sPath.c_str()), GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
- if( !hFile )
- return 0;
+
+ if ( hFile == INVALID_HANDLE_VALUE ) return 0;
+
FILETIME Tcreate,Taccess,Twrite;
if( !GetFileTime( hFile, &Tcreate, &Taccess, &Twrite ) )
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-01-15 18:11:50
|
Revision: 660
http://hgengine.svn.sourceforge.net/hgengine/?rev=660&view=rev
Author: axlecrusher
Date: 2010-01-15 18:11:44 +0000 (Fri, 15 Jan 2010)
Log Message:
-----------
Fix deadlock on windows.
Mutexes can not have a default name. In windows, mutexes with identical names are shared.
Modified Paths:
--------------
Mercury2/src/MScopedArray.h
Mercury2/src/MercuryThreads.cpp
Mercury2/src/MercuryThreads.h
Mercury2/src/ModuleManager.cpp
Modified: Mercury2/src/MScopedArray.h
===================================================================
--- Mercury2/src/MScopedArray.h 2010-01-14 21:30:42 UTC (rev 659)
+++ Mercury2/src/MScopedArray.h 2010-01-15 18:11:44 UTC (rev 660)
@@ -14,9 +14,9 @@
MScopedArray(T* ptr)
:m_ptr(ptr), m_count(NULL)
{
- m_criticalSection.Wait();
+ m_criticalSection.DangerousWait();
IncrementReference();
- m_criticalSection.UnLock();
+ m_criticalSection.DangerousWait();
}
MScopedArray()
@@ -35,26 +35,26 @@
inline ~MScopedArray()
{
- m_criticalSection.Wait();
+ m_criticalSection.DangerousWait();
DecrementReference();
- m_criticalSection.UnLock();
+ m_criticalSection.DangerousUnLock();
}
inline unsigned int Count()
{
unsigned int count = 0;
- m_criticalSection.Wait();
+ m_criticalSection.DangerousWait();
if( m_ptr && m_count ) count = *m_count;
- m_criticalSection.UnLock();
+ m_criticalSection.DangerousUnLock();
return count;
}
void Clear()
{
- m_criticalSection.Wait();
+ m_criticalSection.DangerousWait();
DecrementReference();
m_ptr = NULL;
- m_criticalSection.UnLock();
+ m_criticalSection.DangerousUnLock();
}
/*
void Forget()
@@ -85,11 +85,11 @@
//Assignment
MScopedArray& operator=(const MScopedArray<T>& rhs)
{
- m_criticalSection.Wait();
+ m_criticalSection.DangerousWait();
DecrementReference();
m_ptr = rhs.m_ptr;
IncrementReference();
- m_criticalSection.UnLock();
+ m_criticalSection.DangerousUnLock();
return *this;
}
Modified: Mercury2/src/MercuryThreads.cpp
===================================================================
--- Mercury2/src/MercuryThreads.cpp 2010-01-14 21:30:42 UTC (rev 659)
+++ Mercury2/src/MercuryThreads.cpp 2010-01-15 18:11:44 UTC (rev 660)
@@ -4,6 +4,9 @@
#include <windows.h>
#endif
+//XXX WARNING in windows mutex of the same name are shared!!!
+//we can not give mutexes a default name
+
#include <stdio.h>
MercuryThread::MercuryThread()
@@ -131,7 +134,7 @@
//Mutex functions
MercuryMutex::MercuryMutex( )
-:m_name("(null)")
+:m_heldBy(0)
{
iLockCount = 0;
Open( );
@@ -139,7 +142,7 @@
}
MercuryMutex::MercuryMutex( const MString &name )
-:m_name(name)
+:m_name(name),m_heldBy(0)
{
iLockCount = 0;
Open( );
@@ -151,11 +154,26 @@
Close( );
}
-int MercuryMutex::Wait( long lMilliseconds )
+void MercuryMutex::SetName(const MString& name)
{
+ m_name = name;
+}
+
+bool MercuryMutex::Wait( long lMilliseconds )
+{
int r = 0;
#if defined( WIN32 )
r = WaitForSingleObject( m_mutex, lMilliseconds );
+
+ switch( r )
+ {
+ case WAIT_TIMEOUT:
+ fprintf(stderr, "Mutex held by thread ID 0x%x timed out (%d locks)\n", m_heldBy, iLockCount );
+ return false;
+ case WAIT_FAILED:
+ fprintf(stderr, "Mutex held by thread ID 0x%x failed (%d locks)\n", m_heldBy, iLockCount );
+ return false;
+ }
#else
/* timespec abstime;
abstime.tv_sec = 0;
@@ -172,25 +190,30 @@
// }
#endif
// printf("Locked %s\n", m_name.c_str());
+ m_heldBy = MercuryThread::Current();
++iLockCount;
- return r;
+// return r;
+ return true;
}
-int MercuryMutex::UnLock( )
+bool MercuryMutex::UnLock( )
{
// printf("Unlocked %s\n", m_name.c_str());
--iLockCount;
+ if (iLockCount==0) m_heldBy = 0;
#if defined( WIN32 )
- return ReleaseMutex( m_mutex );
+ bool r = ReleaseMutex( m_mutex )!=0;
+ if (!r) fprintf(stderr, "Failed to release mutex %s, error %d!!\n", m_name.c_str(), GetLastError());
+ return r;
#else
pthread_mutex_unlock( &m_mutex );
- return 0;
+ return true;
#endif
}
int MercuryMutex::Open( )
{
- iLockCount++;
+ ++iLockCount;
#if defined( WIN32 )
SECURITY_ATTRIBUTES *p = ( SECURITY_ATTRIBUTES* ) malloc( sizeof( SECURITY_ATTRIBUTES ) );
p->nLength = sizeof( SECURITY_ATTRIBUTES );
Modified: Mercury2/src/MercuryThreads.h
===================================================================
--- Mercury2/src/MercuryThreads.h 2010-01-14 21:30:42 UTC (rev 659)
+++ Mercury2/src/MercuryThreads.h 2010-01-15 18:11:44 UTC (rev 660)
@@ -22,6 +22,8 @@
class StartThreadData;
#endif
+#include <stdio.h>
+
///Thread object
class MercuryThread
{
@@ -74,13 +76,22 @@
MercuryMutex( const MString &name );
~MercuryMutex();
+ /** These functions are dangerous because you need to be VERY careful to cover all
+ unlock scenarios including errors and exceptions.
+ Recommend using AutoMutexLock on the stack to avoid problems **/
+
///Wait for a mutex to unlock (0xFFFFFF is infinate on windows)
- int Wait( long lMilliseconds = 0xFFFFFF );
+ bool DangerousWait( long lMilliseconds = 0xFFFFFF ) { return Wait(lMilliseconds); } //return false on error
+ /// Unlock a mutex for the next thing waiting in line.
+ bool DangerousUnLock( ) { return UnLock( ); } //return false on error
- ///Unlock a mutex for the next thing waiting in line.
- int UnLock( );
+ inline unsigned long HeldBy() const { return m_heldBy; }
+ void SetName(const MString& name);
private:
+ friend class AutoMutexLock;
+ bool Wait( long lMilliseconds = 0xFFFFFF ); //return false on error
+ bool UnLock( ); //return false on error
///Start up a mutex. You need to do this as well as UnLock() afterwards when in a constructor.
int Open( );
@@ -91,6 +102,7 @@
MString m_name;
int iLockCount;
+ unsigned long m_heldBy;
#if defined( WIN32 )
void * m_mutex;
#else
@@ -109,8 +121,12 @@
AutoMutexLock( MercuryMutex& mutex)
:m_mutex(&mutex)
{
- m_mutex->Wait();
+ //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);
}
+
~AutoMutexLock()
{
m_mutex->UnLock();
Modified: Mercury2/src/ModuleManager.cpp
===================================================================
--- Mercury2/src/ModuleManager.cpp 2010-01-14 21:30:42 UTC (rev 659)
+++ Mercury2/src/ModuleManager.cpp 2010-01-15 18:11:44 UTC (rev 660)
@@ -37,7 +37,8 @@
void ModuleManager::InitializeAllModules()
{
- m_mHandleMutex.Wait();
+ AutoMutexLock lock(m_mHandleMutex);
+
XMLDocument* doc = XMLDocument::Load("modules.xml");
XMLNode r = doc->GetRootNode();
for (XMLNode child = r.Child(); child.IsValid(); child = child.NextNode())
@@ -60,7 +61,7 @@
m_hClassMFunction[child.Attribute( "class" )] = LoadFunct;
LoadModule( ModuleName, LoadFunct );
}
- m_mHandleMutex.UnLock();
+
delete doc;
}
@@ -72,26 +73,27 @@
void * ModuleManager::LoadModule( const MString & ModuleName, const MString & LoadFunction )
{
- m_mHandleMutex.Wait();
+ {
+ //scope mutex lock
+ AutoMutexLock lock(m_mHandleMutex);
- if( m_hAllHandles[ModuleName] ) UnloadModule( ModuleName );
+ if( m_hAllHandles[ModuleName] ) UnloadModule( ModuleName );
- void * v = dlopen( ModuleName.c_str(), RTLD_NOW | RTLD_GLOBAL );
- m_hAllHandles[ModuleName] = v;
+ void * v = dlopen( ModuleName.c_str(), RTLD_NOW | RTLD_GLOBAL );
+ m_hAllHandles[ModuleName] = v;
- if( !m_hAllHandles[ModuleName] )
- {
+ if( !m_hAllHandles[ModuleName] )
+ {
#ifdef WIN32
- fprintf( stderr, "Error opening: %s\n", ModuleName.c_str() );
+ fprintf( stderr, "Error opening: %s\n", ModuleName.c_str() );
#else
- fprintf( stderr, "Error opening: %s (%s)\n", ModuleName.c_str(), dlerror() );
+ fprintf( stderr, "Error opening: %s (%s)\n", ModuleName.c_str(), dlerror() );
#endif
- return false;
+ return false;
+ }
}
- m_mHandleMutex.UnLock();
-
//If no load funct, just exit early.
if( LoadFunction == "" )
return 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-01-14 21:31:21
|
Revision: 659
http://hgengine.svn.sourceforge.net/hgengine/?rev=659&view=rev
Author: axlecrusher
Date: 2010-01-14 21:30:42 +0000 (Thu, 14 Jan 2010)
Log Message:
-----------
fix warnings
Modified Paths:
--------------
Mercury2/Mercury2.vcproj
Mercury2/src/MercuryValue.cpp
Mercury2/src/MercuryValue.h
Modified: Mercury2/Mercury2.vcproj
===================================================================
--- Mercury2/Mercury2.vcproj 2010-01-14 19:36:39 UTC (rev 658)
+++ Mercury2/Mercury2.vcproj 2010-01-14 21:30:42 UTC (rev 659)
@@ -480,6 +480,14 @@
>
</File>
<File
+ RelativePath=".\src\MercuryValue.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\MercuryValue.h"
+ >
+ </File>
+ <File
RelativePath=".\src\MercuryVBO.cpp"
>
</File>
Modified: Mercury2/src/MercuryValue.cpp
===================================================================
--- Mercury2/src/MercuryValue.cpp 2010-01-14 19:36:39 UTC (rev 658)
+++ Mercury2/src/MercuryValue.cpp 2010-01-14 21:30:42 UTC (rev 659)
@@ -74,7 +74,7 @@
{
switch( m_CurType )
{
- case TYPE_INT: return m_Data.l;
+ case TYPE_INT: return (int)m_Data.l;
case TYPE_FLOAT: return m_Data.f;
case TYPE_STRING: return StrToInt(*m_Data.dataS);
default: return 0;
@@ -85,7 +85,7 @@
{
switch( m_CurType )
{
- case TYPE_INT: return m_Data.l;
+ case TYPE_INT: return (float)m_Data.l;
case TYPE_FLOAT: return m_Data.f;
case TYPE_STRING: return StrToFloat(*m_Data.dataS);
default: return 0;
Modified: Mercury2/src/MercuryValue.h
===================================================================
--- Mercury2/src/MercuryValue.h 2010-01-14 19:36:39 UTC (rev 658)
+++ Mercury2/src/MercuryValue.h 2010-01-14 21:30:42 UTC (rev 659)
@@ -52,7 +52,7 @@
float GetFloat() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_FLOAT)?m_Data.f:ConvFloat(); }
const MString GetString() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_STRING)?*m_Data.dataS:ConvString(); }
void GetString( MString & str ) { MSemaphoreLock( &this->m_Sema ); if (m_CurType == TYPE_STRING) str = *m_Data.dataS; else ConvString( str ); }
- bool GetBool() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_INT)?m_Data.l:ConvBool(); }
+ bool GetBool() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_INT)?m_Data.l!=0:ConvBool(); }
void * GetPtr() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_PTR)?m_Data.v:0; }
void SetInt( int iv ) { MSemaphoreLock( &this->m_Sema ); Cleanup(); m_Data.l = iv; m_CurType = TYPE_INT; Notify();}
@@ -167,7 +167,7 @@
MVRefBool( const MString & p ) : MVRefBase( p ) { }
int Get() { return mv->GetBool(); }
- void Set( int iv ) { mv->SetBool( iv ); }
+ void Set( int iv ) { mv->SetBool( iv!=0 ); }
};
///Value Reference for Float objects.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-01-14 19:36:45
|
Revision: 658
http://hgengine.svn.sourceforge.net/hgengine/?rev=658&view=rev
Author: axlecrusher
Date: 2010-01-14 19:36:39 +0000 (Thu, 14 Jan 2010)
Log Message:
-----------
Remove loading message.
Modified Paths:
--------------
Mercury2/modules/ParticleEmitter.cpp
Modified: Mercury2/modules/ParticleEmitter.cpp
===================================================================
--- Mercury2/modules/ParticleEmitter.cpp 2010-01-14 19:34:46 UTC (rev 657)
+++ Mercury2/modules/ParticleEmitter.cpp 2010-01-14 19:36:39 UTC (rev 658)
@@ -207,7 +207,6 @@
void ParticleEmitter::LoadFromXML(const XMLNode& node)
{
- printf("LOADED!!!!!\n");
base::LoadFromXML(node);
/*
XMLNode particleXML;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-01-14 19:34:58
|
Revision: 657
http://hgengine.svn.sourceforge.net/hgengine/?rev=657&view=rev
Author: axlecrusher
Date: 2010-01-14 19:34:46 +0000 (Thu, 14 Jan 2010)
Log Message:
-----------
Fix windows compiling.
Fix shader compiling multiple times.
Fix shader destruction when opengl driver gives successful link message.
Modified Paths:
--------------
Mercury2/src/DataStructures/SpatialHash.h
Mercury2/src/MercuryAsset.cpp
Mercury2/src/Shader.cpp
Modified: Mercury2/src/DataStructures/SpatialHash.h
===================================================================
--- Mercury2/src/DataStructures/SpatialHash.h 2010-01-13 12:06:26 UTC (rev 656)
+++ Mercury2/src/DataStructures/SpatialHash.h 2010-01-14 19:34:46 UTC (rev 657)
@@ -1,7 +1,7 @@
#ifndef SPATIALHASH_H
#define SPATIALHASH_H
-#include <stdint.h>
+//#include <stdint.h>
#include <list>
#include <math.h>
Modified: Mercury2/src/MercuryAsset.cpp
===================================================================
--- Mercury2/src/MercuryAsset.cpp 2010-01-13 12:06:26 UTC (rev 656)
+++ Mercury2/src/MercuryAsset.cpp 2010-01-14 19:34:46 UTC (rev 657)
@@ -3,6 +3,8 @@
#include <MercuryNode.h>
#include <GLHeaders.h>
+#include <time.h>
+
extern bool DOOCCLUSIONCULL;
MercuryAsset::MercuryAsset( const MString & key, bool bInstanced )
@@ -192,7 +194,7 @@
void AssetFactory::RemoveAssetInstance(const MString& key)
{
m_assetInstances.remove( key );
- puts( "removed asset "+key );
+ LOG.Write("removed asset "+key);
}
/****************************************************************************
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2010-01-13 12:06:26 UTC (rev 656)
+++ Mercury2/src/Shader.cpp 2010-01-14 19:34:46 UTC (rev 657)
@@ -94,6 +94,9 @@
fPriority = StrToFloat( node.Attribute("priority" ) );
ChangeKey( node.Attribute("file") );
+
+ if (iProgramID == NULL)
+ LoadShader();
}
bool Shader::ChangeKey( const MString& path )
@@ -102,7 +105,7 @@
return true;
sShaderName = path;
- LoadShader( );
+// LoadShader( );
return MercuryAsset::ChangeKey( path );
}
@@ -206,8 +209,7 @@
{
char * tmpstr = (char*)malloc( stringLength + 1 );
GLCALL( glGetInfoLogARB( fragmentShader, stringLength, NULL, tmpstr ) );
- puts( "Compiling Fragment Shader response follows:" );
- puts( tmpstr );
+ LOG.Write( ssprintf("Compiling Fragment Shader response follows:%s" ,tmpstr) );
free( tmpstr );
return bFragCompiled!=0;
}
@@ -234,8 +236,7 @@
{
char * tmpstr = (char*)malloc( stringLength + 1 );
GLCALL( glGetInfoLogARB( vertexShader, stringLength, NULL, tmpstr ) );
- puts( "Compiling Vertex Shader response follows:" );
- puts( tmpstr );
+ LOG.Write( ssprintf("Compiling Vertex Shader response follows:%s", tmpstr) );
free( tmpstr );
return bVertCompiled!=0;
}
@@ -263,8 +264,7 @@
{
char * tmpstr = (char*)malloc( stringLength + 1 );
GLCALL( glGetInfoLogARB( geometryShader, stringLength, NULL, tmpstr ) );
- puts( "Compiling Geometry Shader response follows:" );
- puts( tmpstr );
+ LOG.Write( ssprintf("Compiling Geometry Shader response follows:%s",tmpstr) );
free( tmpstr );
return bGeomCompiled!=0;
}
@@ -304,8 +304,8 @@
GLCALL( glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT,&imaxvert) );
if( (ierror = glGetError()) != 0 )
{
- puts( "ERROR: You cannot load a geometry shader when there are still errors left in OpenGL." );
- puts( "Please track down the error remaining by using glGetError() to cordon off your code." );
+ LOG.Write( "ERROR: You cannot load a geometry shader when there are still errors left in OpenGL." );
+ LOG.Write( "Please track down the error remaining by using glGetError() to cordon off your code." );
LOG.Write( ssprintf( "The last error received was: %d", ierror ) );
}
for( i = 1; i < imaxvert; i++ )
@@ -326,11 +326,14 @@
{
char * tmpstr = (char*)malloc( stringLength + 1 );
GLCALL( glGetInfoLogARB( iProgramID, stringLength, NULL, tmpstr ) );
- puts( "Linking shaders. response follows:" );
- puts( tmpstr );
+ LOG.Write( ssprintf("Linking shaders. response follows:%s",tmpstr) );
free( tmpstr );
+ }
+
+ if (bLinked == 0)
+ {
DestroyShader();
- return bLinked!=0;
+ return false;
}
//Build the list of uniform tabs.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-01-13 12:06:32
|
Revision: 656
http://hgengine.svn.sourceforge.net/hgengine/?rev=656&view=rev
Author: axlecrusher
Date: 2010-01-13 12:06:26 +0000 (Wed, 13 Jan 2010)
Log Message:
-----------
correct timed reload
Modified Paths:
--------------
Mercury2/src/MercuryAsset.cpp
Modified: Mercury2/src/MercuryAsset.cpp
===================================================================
--- Mercury2/src/MercuryAsset.cpp 2010-01-11 22:31:04 UTC (rev 655)
+++ Mercury2/src/MercuryAsset.cpp 2010-01-13 12:06:26 UTC (rev 656)
@@ -54,10 +54,11 @@
void MercuryAsset::PreRender(const MercuryNode* node)
{
uint32_t t = time(0);
- if ( CheckForNewer() && (m_lastNewerCheck < t) )
+ if ( m_lastNewerCheck < t )
{
m_lastNewerCheck = t;
- Reload();
+ if ( CheckForNewer() )
+ Reload();
}
/*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-01-11 22:31:14
|
Revision: 655
http://hgengine.svn.sourceforge.net/hgengine/?rev=655&view=rev
Author: axlecrusher
Date: 2010-01-11 22:31:04 +0000 (Mon, 11 Jan 2010)
Log Message:
-----------
ability for assets to reload if there is a newer version
Modified Paths:
--------------
Mercury2/src/FullscreenQuad.h
Mercury2/src/HGMDLModel.cpp
Mercury2/src/HGMDLModel.h
Mercury2/src/ImageLoader.cpp
Mercury2/src/MercuryAsset.cpp
Mercury2/src/MercuryAsset.h
Mercury2/src/MercuryVBO.h
Mercury2/src/Quad.h
Mercury2/src/RenderDeferredLights.h
Mercury2/src/Shader.cpp
Mercury2/src/Shader.h
Mercury2/src/StateChanger.h
Mercury2/src/Texture.cpp
Mercury2/src/Texture.h
Modified: Mercury2/src/FullscreenQuad.h
===================================================================
--- Mercury2/src/FullscreenQuad.h 2010-01-11 21:56:22 UTC (rev 654)
+++ Mercury2/src/FullscreenQuad.h 2010-01-11 22:31:04 UTC (rev 655)
@@ -13,6 +13,10 @@
virtual void Render(const MercuryNode* node);
GENRTTI( FullscreenQuad );
+ protected:
+ virtual bool CheckForNewer() { return false; }
+ virtual void Reload() {};
+
private:
MercuryMatrix m_matrix;
};
Modified: Mercury2/src/HGMDLModel.cpp
===================================================================
--- Mercury2/src/HGMDLModel.cpp 2010-01-11 21:56:22 UTC (rev 654)
+++ Mercury2/src/HGMDLModel.cpp 2010-01-11 22:31:04 UTC (rev 655)
@@ -7,7 +7,7 @@
const uint16_t EXPCTMNRV = 3;
HGMDLModel::HGMDLModel( const MString & key, bool bInstanced )
- :MercuryAsset( key, bInstanced )
+ :MercuryAsset( key, bInstanced ), m_timeStamp( 0 )
{
}
@@ -17,12 +17,35 @@
void HGMDLModel::LoadFromXML(const XMLNode& node)
{
- MString path = node.Attribute("file");
+ LoadFromFile( node.Attribute("file") );
+ MercuryAsset::LoadFromXML( node );
+}
+
+
+void HGMDLModel::LoadFromFile(const MString& path)
+{
+ m_path = path;
ChangeKey( path );
+}
+
+bool HGMDLModel::CheckForNewer()
+{
+ uint32_t t = 0;
+ MercuryFile *f = FILEMAN.Open(m_path);
- MercuryAsset::LoadFromXML( node );
+ if (f)
+ {
+ t = f->GetModTime();
+ delete f;
+ }
+ return t != m_timeStamp;
}
+void HGMDLModel::Reload()
+{
+ LoadFromFile(m_path);
+}
+
void HGMDLModel::LoadModel(MercuryFile* hgmdl, HGMDLModel* model)
{
char fingerPrint[5];
Modified: Mercury2/src/HGMDLModel.h
===================================================================
--- Mercury2/src/HGMDLModel.h 2010-01-11 21:56:22 UTC (rev 654)
+++ Mercury2/src/HGMDLModel.h 2010-01-11 22:31:04 UTC (rev 655)
@@ -12,6 +12,7 @@
~HGMDLModel();
virtual void LoadFromXML(const XMLNode& node);
+ void LoadFromFile(const MString& path);
static void LoadModel(MercuryFile* hgmdl, HGMDLModel* model);
@@ -21,11 +22,16 @@
virtual void Render(const MercuryNode* node);
GENRTTI( HGMDLModel );
protected:
+ virtual bool CheckForNewer();
+ virtual void Reload();
+
MVector< MAutoPtr< HGMDLMesh > > m_meshes;
private:
CLASS_HELPERS( MercuryAsset );
static void* LoaderThread(void* d);
+
+ uint32_t m_timeStamp;
};
Modified: Mercury2/src/ImageLoader.cpp
===================================================================
--- Mercury2/src/ImageLoader.cpp 2010-01-11 21:56:22 UTC (rev 654)
+++ Mercury2/src/ImageLoader.cpp 2010-01-11 22:31:04 UTC (rev 655)
@@ -56,11 +56,12 @@
if (i->first == t)
{
RawImageData* d = i->second(f);
- delete f;
+ SAFE_DELETE(f);
return d;
}
}
- delete f;
+
+ SAFE_DELETE(f);
return NULL;
}
Modified: Mercury2/src/MercuryAsset.cpp
===================================================================
--- Mercury2/src/MercuryAsset.cpp 2010-01-11 21:56:22 UTC (rev 654)
+++ Mercury2/src/MercuryAsset.cpp 2010-01-11 22:31:04 UTC (rev 655)
@@ -6,7 +6,7 @@
extern bool DOOCCLUSIONCULL;
MercuryAsset::MercuryAsset( const MString & key, bool bInstanced )
- :slType( 0 ), m_isInstanced(bInstanced), m_boundingVolume(NULL), m_path( key ), m_loadState(NONE), m_ignoreCull(false), m_iPasses( DEFAULT_PASSES )
+ :slType( 0 ), m_isInstanced(bInstanced), m_boundingVolume(NULL), m_path( key ), m_loadState(NONE), m_ignoreCull(false), m_iPasses( DEFAULT_PASSES ), m_lastNewerCheck(0)
{
}
@@ -53,6 +53,13 @@
void MercuryAsset::PreRender(const MercuryNode* node)
{
+ uint32_t t = time(0);
+ if ( CheckForNewer() && (m_lastNewerCheck < t) )
+ {
+ m_lastNewerCheck = t;
+ Reload();
+ }
+
/*
MercuryNode* n = const_cast<MercuryNode*>(node);
if ( m_boundingVolume )
Modified: Mercury2/src/MercuryAsset.h
===================================================================
--- Mercury2/src/MercuryAsset.h 2010-01-11 21:56:22 UTC (rev 654)
+++ Mercury2/src/MercuryAsset.h 2010-01-11 22:31:04 UTC (rev 655)
@@ -84,14 +84,21 @@
protected:
void SetLoadState(LoadState ls); //thread safe
+ virtual bool CheckForNewer() = 0;
+ virtual void Reload() = 0;
+
bool m_isInstanced;
BoundingVolume* m_boundingVolume;
MString m_path;
+
private:
LoadState m_loadState;
MSemaphore m_lock;
bool m_ignoreCull;
unsigned short m_iPasses;
+
+ uint32_t m_lastNewerCheck;
+// uint32_t m_timeStamp; //creation timestamp of asset eg. file timestamp
};
/** This holds the per-instance data for each asset instance.
Modified: Mercury2/src/MercuryVBO.h
===================================================================
--- Mercury2/src/MercuryVBO.h 2010-01-11 21:56:22 UTC (rev 654)
+++ Mercury2/src/MercuryVBO.h 2010-01-11 22:31:04 UTC (rev 655)
@@ -46,6 +46,10 @@
inline static void IncrementBatches() { ++m_vboBatches; }
GENRTTI( MercuryVBO );
+ protected:
+ virtual bool CheckForNewer() { return false; }
+ virtual void Reload() {};
+
private:
virtual void InitVBO();
static void* m_lastVBOrendered;
Modified: Mercury2/src/Quad.h
===================================================================
--- Mercury2/src/Quad.h 2010-01-11 21:56:22 UTC (rev 654)
+++ Mercury2/src/Quad.h 2010-01-11 22:31:04 UTC (rev 655)
@@ -14,6 +14,9 @@
virtual bool ChangeKey( const MString & sDescription );
GENRTTI( Quad );
+ protected:
+ virtual bool CheckForNewer() { return false; }
+ virtual void Reload() {};
private:
bool m_bFlipV;
Modified: Mercury2/src/RenderDeferredLights.h
===================================================================
--- Mercury2/src/RenderDeferredLights.h 2010-01-11 21:56:22 UTC (rev 654)
+++ Mercury2/src/RenderDeferredLights.h 2010-01-11 22:31:04 UTC (rev 655)
@@ -11,6 +11,9 @@
virtual void Render(const MercuryNode* node);
GENRTTI( RenderDeferredLights );
+ protected:
+ virtual bool CheckForNewer() { return false; }
+ virtual void Reload() {};
};
#endif
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2010-01-11 21:56:22 UTC (rev 654)
+++ Mercury2/src/Shader.cpp 2010-01-11 22:31:04 UTC (rev 655)
@@ -384,16 +384,21 @@
return;
}
-void Shader::CheckForNewer( )
+void Shader::Reload()
{
+ DestroyShader( );
+ LoadShader( );
+}
+
+bool Shader::CheckForNewer()
+{
unsigned long iCurTimes[3];
GetTimeCodes( iCurTimes );
if( iCurTimes[0] != iTimeCode[0] || iCurTimes[1] != iTimeCode[1] || iCurTimes[2] != iTimeCode[2] )
- {
- DestroyShader( );
- LoadShader( );
- }
+ return true;
+
+ return false;
}
void Shader::GetTimeCodes( unsigned long * iOut )
Modified: Mercury2/src/Shader.h
===================================================================
--- Mercury2/src/Shader.h 2010-01-11 21:56:22 UTC (rev 654)
+++ Mercury2/src/Shader.h 2010-01-11 22:31:04 UTC (rev 655)
@@ -90,6 +90,11 @@
///Explicitly get the OpenGL ProgramID in the event you need it for advanced techniques
unsigned int GetProgramID() { return iProgramID; }
inline static Shader* GetCurrentShader() { return CurrentShader; }
+
+ protected:
+ virtual bool CheckForNewer();
+ virtual void Reload();
+
private:
int32_t GetUniformLocation(const MString& n);
@@ -127,7 +132,7 @@
bool LinkShaders();
///Check for newer version of 'this' shader
- void CheckForNewer( );
+// void CheckForNewer( );
///Get the last modified time for sShaderName
/* This function takes on iOut as being where to put the last time the shader was modified.
Modified: Mercury2/src/StateChanger.h
===================================================================
--- Mercury2/src/StateChanger.h 2010-01-11 21:56:22 UTC (rev 654)
+++ Mercury2/src/StateChanger.h 2010-01-11 22:31:04 UTC (rev 655)
@@ -64,6 +64,10 @@
virtual bool ChangeKey( const MString & sNewKey );
virtual bool LoadInternal( const MString & sFile );
GENRTTI( StateChanger );
+
+ protected:
+ virtual bool CheckForNewer() { return false; }
+ virtual void Reload() {};
private:
MVector< MAutoPtr< StateChange > > m_vStates;
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2010-01-11 21:56:22 UTC (rev 654)
+++ Mercury2/src/Texture.cpp 2010-01-11 22:31:04 UTC (rev 655)
@@ -13,7 +13,7 @@
#define BUFFER_OFFSET(i) ((char*)NULL + (i))
Texture::Texture( const MString & key, bool bInstanced )
- :MercuryAsset( key, bInstanced ), m_raw(NULL),m_textureID(0),m_bDeleteRaw(true),m_dynamic(false), m_bClamp(true), m_tFilterMode(TF_LINEAR_MIPS)
+ :MercuryAsset( key, bInstanced ), m_raw(NULL),m_textureID(0),m_bDeleteRaw(true),m_dynamic(false), m_bClamp(true), m_tFilterMode(TF_LINEAR_MIPS), m_timeStamp(0)
{
if (!m_initTextureSuccess)
{
@@ -292,6 +292,27 @@
GLERRORCHECK;
}
+bool Texture::CheckForNewer()
+{
+ uint32_t timeStamp = m_timeStamp;
+
+ if (timeStamp == 0) return false;
+
+ MercuryFile *f = FILEMAN.Open(m_path);
+ if (f)
+ {
+ m_timeStamp = f->GetModTime();
+ delete f;
+ }
+
+ return timeStamp != m_timeStamp;
+}
+
+void Texture::Reload()
+{
+ LoadImagePath(m_path);
+}
+
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-01-11 21:56:22 UTC (rev 654)
+++ Mercury2/src/Texture.h 2010-01-11 22:31:04 UTC (rev 655)
@@ -47,9 +47,13 @@
static void DisableUnusedTextures();
void SetFilter( TextureFilterMode t ) { m_tFilterMode = t; }
+ GENRTTI( Texture );
+ protected:
+ virtual bool CheckForNewer();
+ virtual void Reload();
- GENRTTI( Texture );
private:
+
void LoadImagePath(const MString& path);
void BindTexture();
@@ -59,7 +63,7 @@
void Deactivate(uint32_t textureResource);
void InitiateBindCache();
-
+
RawImageData* m_raw;
uint32_t m_textureID;
@@ -75,7 +79,7 @@
bool m_dynamic;
bool m_bClamp;
TextureFilterMode m_tFilterMode;
-
+ uint32_t m_timeStamp;
};
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2010-01-11 21:56:29
|
Revision: 654
http://hgengine.svn.sourceforge.net/hgengine/?rev=654&view=rev
Author: cnlohr
Date: 2010-01-11 21:56:22 +0000 (Mon, 11 Jan 2010)
Log Message:
-----------
update shader to reflect change in way MercuryFile works.
Modified Paths:
--------------
Mercury2/src/Shader.cpp
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2010-01-11 21:53:23 UTC (rev 653)
+++ Mercury2/src/Shader.cpp 2010-01-11 21:56:22 UTC (rev 654)
@@ -138,16 +138,14 @@
i = f1->Length();
Buffer = (char*)malloc( i+1 );
f1->Read( Buffer, i );
- f1->Close();
+ SAFE_DELETE( f1 );
LOG.Write( "Compiling: " + s1 );
Buffer[i] = '\0';
if( !LoadShaderFrag( Buffer ) )
{
free( Buffer );
- if( f2 )
- f2->Close();
- if( f3 )
- f3->Close();
+ SAFE_DELETE( f2 );
+ SAFE_DELETE( f3 );
LOG.Write("Reporting failed shaderload. Not linking." );
return false;
}
@@ -158,13 +156,13 @@
i = f2->Length();
Buffer = (char*)malloc( i+1 );
f2->Read( Buffer, i );
- f2->Close();
+ SAFE_DELETE( f2 );
Buffer[i] = '\0';
LOG.Write("Compiling: "+s2);
if( !LoadShaderVert( Buffer ) )
{
if( f3 )
- f3->Close();
+ SAFE_DELETE( f3 );
free( Buffer );
LOG.Write("Reporting failed shaderload. Not linking." );
return false;
@@ -176,7 +174,7 @@
i = f3->Length();
Buffer = (char*)malloc( i+1 );
f3->Read( Buffer, i );
- f3->Close();
+ SAFE_DELETE( f3 );
Buffer[i] = '\0';
LOG.Write("Compiling: "+s3);
if( !LoadShaderGeom( Buffer ) )
@@ -404,7 +402,7 @@
if( f )
{
iOut[0] = f->GetModTime();
- f->Close();
+ delete f;
} else
iOut[0] = 0;
@@ -412,7 +410,7 @@
if( f )
{
iOut[1] = f->GetModTime();
- f->Close();
+ delete f;
} else
iOut[1] = 0;
@@ -420,7 +418,7 @@
if( f )
{
iOut[2] = f->GetModTime();
- f->Close();
+ delete f;
} else
iOut[2] = 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2010-01-11 21:53:32
|
Revision: 653
http://hgengine.svn.sourceforge.net/hgengine/?rev=653&view=rev
Author: cnlohr
Date: 2010-01-11 21:53:23 +0000 (Mon, 11 Jan 2010)
Log Message:
-----------
tweak operations
Modified Paths:
--------------
Mercury2/src/MercuryFileDriverDirect.cpp
Modified: Mercury2/src/MercuryFileDriverDirect.cpp
===================================================================
--- Mercury2/src/MercuryFileDriverDirect.cpp 2010-01-11 20:21:50 UTC (rev 652)
+++ Mercury2/src/MercuryFileDriverDirect.cpp 2010-01-11 21:53:23 UTC (rev 653)
@@ -27,7 +27,6 @@
MercuryFile::~MercuryFile()
{
- //No code
}
bool MercuryFile::Init( const MString &sPath, FilePermission p )
@@ -69,11 +68,7 @@
MercuryFileObjectDirect::~MercuryFileObjectDirect()
{
- if ( m_fF != NULL )
- {
- fclose ( m_fF );
- m_fF = NULL;
- }
+ Close();
}
void MercuryFileObjectDirect::Close()
@@ -83,7 +78,6 @@
fclose ( m_fF );
m_fF = NULL;
}
- delete this;
}
bool MercuryFileObjectDirect::Init( const MString & fName, FilePermission p )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2010-01-11 20:21:56
|
Revision: 652
http://hgengine.svn.sourceforge.net/hgengine/?rev=652&view=rev
Author: cnlohr
Date: 2010-01-11 20:21:50 +0000 (Mon, 11 Jan 2010)
Log Message:
-----------
better support for values
Modified Paths:
--------------
Mercury2/Themes/default/File/scenegraph.xml
Mercury2/modules/Cu2.cpp
Mercury2/modules/Cu2.h
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryValue.cpp
Mercury2/src/MercuryValue.h
Modified: Mercury2/Themes/default/File/scenegraph.xml
===================================================================
--- Mercury2/Themes/default/File/scenegraph.xml 2010-01-11 19:24:25 UTC (rev 651)
+++ Mercury2/Themes/default/File/scenegraph.xml 2010-01-11 20:21:50 UTC (rev 652)
@@ -72,7 +72,9 @@
<node type="Cu2Root" width="640" height="480" hidden="true" >
<node type="Cu2Button" text="hello" font="FONT:FreeSans.hgfont" size=".25" alignment="CENTER" x="10" y="450" name="Button" />
<node type="Cu2Dialog" text="T00" font="FONT:FreeSans.hgfont" size=".25" x="200" y="40" name="Dialog" >
- <node type="Cu2Button" text="hel0" font="FONT:FreeSans.hgfont" size=".25" alignment="CENTER" x="10" y="40" />
+ <node type="Cu2Button" text="A" font="FONT:FreeSans.hgfont" size=".25" alignment="CENTER" x="32" y="40" associatedValue="TestMode" associatedValueSet="A" />
+ <node type="Cu2Button" text="B" font="FONT:FreeSans.hgfont" size=".25" alignment="CENTER" x="10" y="40" associatedValue="TestMode" associatedValueSet="B"/>
+ <node type="Cu2Label" text="[nil]" font="FONT:FreeSans.hgfont" size=".25" alignment="CENTER" x="10" y="10" associatedValue="TestMode" />
</node>
</node>
</node>
Modified: Mercury2/modules/Cu2.cpp
===================================================================
--- Mercury2/modules/Cu2.cpp 2010-01-11 19:24:25 UTC (rev 651)
+++ Mercury2/modules/Cu2.cpp 2010-01-11 20:21:50 UTC (rev 652)
@@ -324,6 +324,8 @@
LOAD_FROM_XML( "text", m_sText, );
LOAD_FROM_XML( "autoSize", m_bAutoSize, StrToBool );
LOAD_FROM_XML( "clickPayload", m_sValueToSend, );
+ LOAD_FROM_XML( "associatedValue", m_sAssociatedValue, );
+ LOAD_FROM_XML( "associatedValueSet", m_sAssociatedValueSet, );
if( m_pText )
{
@@ -346,6 +348,8 @@
if( m_sMessageToSend.length() ) sXMLStream += ssprintf( "clickMessage=\"%s\" ", m_sMessageToSend.c_str() );
if( m_sValueToSend.length() ) sXMLStream += ssprintf( "clickPayload=\"%s\" ", m_sValueToSend.c_str() );
if( m_bAutoSize ) sXMLStream += ssprintf( "autoSize=\"%d\" ", m_bAutoSize );
+ if( m_sAssociatedValue.length() ) sXMLStream += ssprintf( "associatedValue=\"%s\" ", m_sAssociatedValue.c_str() );
+ if( m_sAssociatedValueSet.length() ) sXMLStream += ssprintf( "associatedValueSet=\"%s\" ", m_sAssociatedValueSet.c_str() );
if( !m_pText )
m_pText->SaveToXMLTag( sXMLStream );
@@ -391,6 +395,9 @@
void Cu2Button::Click( int x, int y )
{
+ if( m_sAssociatedValue.length() )
+ MESSAGEMAN.GetValue( m_sAssociatedValue )->SetString( m_sAssociatedValueSet );
+
if( m_sMessageToSend.length() )
MESSAGEMAN.BroadcastMessage( m_sMessageToSend, new PointerDataMessage( this ) );
}
@@ -438,6 +445,90 @@
REGISTER_NODE_TYPE(Cu2Button);
+///////////////////////////////////////COPPER 2 LABEL///////////////////////////////////////
+
+Cu2Label::Cu2Label() : Cu2Element()
+{
+ m_pText = (TextNode*)NODEFACTORY.Generate( "TextNode" );
+ AddChild( m_pText );
+ m_bAutoSize = true;
+ m_bDown = false;
+}
+
+Cu2Label::~Cu2Label()
+{
+ if( m_sAssociatedValue.length() )
+ MESSAGEMAN.GetValue( m_sAssociatedValue )->DetachModifyDelegate( (ValueDelegate)&Cu2Label::ChangeValue, this );
+}
+
+void Cu2Label::LoadFromXML(const XMLNode& node)
+{
+ LOAD_FROM_XML( "associatedValue", m_sAssociatedValue, );
+ if( m_sAssociatedValue.length() )
+ {
+ MESSAGEMAN.GetValue( m_sAssociatedValue )->AttachModifyDelegate( (ValueDelegate)&Cu2Label::ChangeValue, this );
+ printf( "Associating Value: %s\n", m_sAssociatedValue.c_str() );
+ }
+
+ LOAD_FROM_XML( "text", m_sText, );
+ LOAD_FROM_XML( "autoSize", m_bAutoSize, StrToBool );
+
+ if( m_pText )
+ {
+ m_pText->SetAlignment( TextNode::LEFT );
+ m_pText->LoadFont( node.Attribute("font") );
+ m_pText->SetSize( StrToFloat( node.Attribute("size") ) );
+ SetText( m_sText );
+ m_pText->SetShiftAbsolute( true );
+ m_pText->SetShiftX( 5 );
+ m_pText->SetShiftY( 5 );
+ }
+
+ Cu2Element::LoadFromXML( node );
+
+ Refresh();
+}
+
+void Cu2Label::SaveToXMLTag( MString & sXMLStream )
+{
+ if( m_sAssociatedValue.length() ) sXMLStream += ssprintf( "m_sAssociatedValue=\"%s\" ", m_sAssociatedValue.c_str() );
+ if( m_bAutoSize ) sXMLStream += ssprintf( "autoSize=\"%d\" ", m_bAutoSize );
+
+ if( !m_pText )
+ m_pText->SaveToXMLTag( sXMLStream );
+
+ Cu2Element::SaveToXMLTag( sXMLStream );
+}
+void Cu2Label::Refresh()
+{
+ if( !m_pText )
+ {
+ LOG.Write( "Warning: Cu2Button \"" + GetName() + "\" does not have valid Text box associated." );
+ return;
+ }
+
+ m_pText->SetText( m_sText );
+ m_pText->RenderText();
+
+ if( m_bAutoSize )
+ {
+ SetSize( m_pText->GetRMaxX() + 8, m_pText->GetRMaxY() + 8 );
+ }
+}
+
+void Cu2Label::Render( const MercuryMatrix& m )
+{
+ TransformNode::Render( m );
+}
+
+void Cu2Label::ChangeValue( MValue * v )
+{
+ m_sText = v->GetString();
+ Refresh();
+}
+
+REGISTER_NODE_TYPE(Cu2Label);
+
///////////////////////////////////////COPPER 2 DIALOG///////////////////////////////////////
Modified: Mercury2/modules/Cu2.h
===================================================================
--- Mercury2/modules/Cu2.h 2010-01-11 19:24:25 UTC (rev 651)
+++ Mercury2/modules/Cu2.h 2010-01-11 20:21:50 UTC (rev 652)
@@ -170,6 +170,9 @@
GENRTTI( Cu2Button );
private:
+ MString m_sAssociatedValue;
+ MString m_sAssociatedValueSet;
+
MString m_sMessageToSend;
MString m_sValueToSend;
MString m_sText;
@@ -178,6 +181,39 @@
TextNode * m_pText;
};
+///Standard label (doesn't do anything but display something)
+class Cu2Label : public Cu2Element
+{
+public:
+ Cu2Label();
+ ~Cu2Label();
+
+ virtual void LoadFromXML(const XMLNode& node);
+ virtual void SaveToXMLTag( MString & sXMLStream );
+
+ virtual void Render( const MercuryMatrix& m );
+
+ void SetText( const MString & sText ) { m_sText = sText; Refresh(); }
+ void SetAutoSize( bool bAutoSize ) { m_bAutoSize = bAutoSize; Refresh(); }
+ void Refresh();
+
+ MString & Payload() { return m_sValueToSend; }
+ TextNode * GetTextNodeHandle() { return m_pText; }
+
+ void ChangeValue( MValue * v );
+
+ GENRTTI( Cu2Button );
+private:
+ MString m_sAssociatedValue;
+ MString m_sMessageToSend;
+ MString m_sValueToSend;
+ MString m_sText;
+ bool m_bAutoSize;
+ bool m_bDown;
+ TextNode * m_pText;
+};
+
+///Dialog box (for putting other things into and being able to drag around)
class Cu2Dialog : public Cu2Element
{
public:
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2010-01-11 19:24:25 UTC (rev 651)
+++ Mercury2/src/Mercury2.cpp 2010-01-11 20:21:50 UTC (rev 652)
@@ -211,12 +211,12 @@
public:
TestMouse()
{
- MESSAGEMAN.GetValue( "Input.CursorGrabbed" )->AttachModifyDelegate( (ValueDelegate)&TestMouse::ChangeX, (MessageHandler*)this );
+ MESSAGEMAN.GetValue( "TestMode" )->AttachModifyDelegate( (ValueDelegate)&TestMouse::ChangeX, (MessageHandler*)this );
}
void ChangeX( MValue * v )
{
- printf( "Changed: %d\n", v->GetBool() );
+ printf( "Changed: %s\n", v->GetString().c_str() );
}
} TM;
///XXXXXXX REMOVE THIS CODE BEFORE ANY RELEASE XXXXXXXXXXx
Modified: Mercury2/src/MercuryValue.cpp
===================================================================
--- Mercury2/src/MercuryValue.cpp 2010-01-11 19:24:25 UTC (rev 651)
+++ Mercury2/src/MercuryValue.cpp 2010-01-11 20:21:50 UTC (rev 652)
@@ -93,19 +93,31 @@
}
-const MString & MValue::ConvString()
+const MString MValue::ConvString()
{
- static const MString NILVAL = "(NIL)";
switch( m_CurType )
{
case TYPE_STRING: return *m_Data.dataS;
- case TYPE_INT: ssprintf( "%d", m_Data.l );
- case TYPE_FLOAT: ssprintf( "%f", m_Data.f );
- case TYPE_PTR: ssprintf( "%p", m_Data.v );
- default: return NILVAL;
+ case TYPE_INT: return ssprintf( "%d", m_Data.l );
+ case TYPE_FLOAT: return ssprintf( "%.2f", m_Data.f );
+ case TYPE_PTR: return ssprintf( "%p", m_Data.v );
+ default: return "(NIL)";
}
}
+void MValue::ConvString( MString & ret )
+{
+ switch( m_CurType )
+ {
+ case TYPE_STRING: ret = *m_Data.dataS;
+ case TYPE_INT: ret = ssprintf( "%d", m_Data.l );
+ case TYPE_FLOAT: ret = ssprintf( "%.2f", m_Data.f );
+ case TYPE_PTR: ret = ssprintf( "%p", m_Data.v );
+ default: ret = "(NIL)";
+ }
+}
+
+
bool MValue::ConvBool()
{
switch( m_CurType )
@@ -117,6 +129,22 @@
}
}
+
+
+void MValue::AttachModifyDelegate( DeletionNotifier NotifyFunction, MessageHandler * NotifyObject )
+{
+ DelegateNotifierList * d = new DelegateNotifierList( NotifyFunction, NotifyObject );
+ d->Next = DLModify;
+ DLModify = d;
+}
+
+void MValue::DetachModifyDelegate( DeletionNotifier NotifyFunction, MessageHandler * NotifyObject )
+{
+ DLModify->DelNotifier( NotifyFunction, NotifyObject, DLModify );
+}
+
+
+
MVRefBase::MVRefBase(const MString & sPath)
{
mv = MESSAGEMAN.GetValue( sPath );
Modified: Mercury2/src/MercuryValue.h
===================================================================
--- Mercury2/src/MercuryValue.h 2010-01-11 19:24:25 UTC (rev 651)
+++ Mercury2/src/MercuryValue.h 2010-01-11 20:21:50 UTC (rev 652)
@@ -50,7 +50,8 @@
int GetInt() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_INT)?m_Data.l:ConvInt(); }
float GetFloat() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_FLOAT)?m_Data.f:ConvFloat(); }
- const MString & GetString() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_STRING)?*m_Data.dataS:ConvString(); }
+ const MString GetString() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_STRING)?*m_Data.dataS:ConvString(); }
+ void GetString( MString & str ) { MSemaphoreLock( &this->m_Sema ); if (m_CurType == TYPE_STRING) str = *m_Data.dataS; else ConvString( str ); }
bool GetBool() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_INT)?m_Data.l:ConvBool(); }
void * GetPtr() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_PTR)?m_Data.v:0; }
@@ -83,19 +84,15 @@
MVType GetType() { return m_CurType; }
- void AttachModifyDelegate( DeletionNotifier NotifyFunction, MessageHandler * NotifyObject )
- {
- DelegateNotifierList * d = new DelegateNotifierList( NotifyFunction, NotifyObject );
- d->Next = DLModify;
- DLModify = d;
- }
-
+ void AttachModifyDelegate( DeletionNotifier NotifyFunction, MessageHandler * NotifyObject );
+ void DetachModifyDelegate( DeletionNotifier NotifyFunction, MessageHandler * NotifyObject );
void SetReferences( short RefCount ) { m_References = RefCount; }
private:
//Conv functions are not thread protected - this is because the caller of these functions should be.
int ConvInt();
float ConvFloat();
- const MString & ConvString();
+ const MString ConvString();
+ void ConvString( MString & ret );
bool ConvBool();
//Cleanup (to be done when object is deleted or switching types)
@@ -191,7 +188,7 @@
MVRefString( MValue * m ) : MVRefBase( m ) { }
MVRefString( const MString & p ) : MVRefBase( p ) { }
- const MString & Get() { return mv->GetString(); }
+ const MString Get() { return mv->GetString(); }
void Set( const MString & sv ) { mv->SetString( sv ); }
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2010-01-11 19:24:36
|
Revision: 651
http://hgengine.svn.sourceforge.net/hgengine/?rev=651&view=rev
Author: cnlohr
Date: 2010-01-11 19:24:25 +0000 (Mon, 11 Jan 2010)
Log Message:
-----------
transition to values for all things that really should be using. I don't think anything else should be transitioned... ever. But, this does finally open the door to making Cu2 pretty serious.
Modified Paths:
--------------
Mercury2/modules/Cu2.cpp
Mercury2/modules/Cu2.h
Mercury2/src/Camera.cpp
Mercury2/src/Camera.h
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryInput.cpp
Mercury2/src/MercuryValue.h
Mercury2/src/MercuryWindow.cpp
Mercury2/src/MercuryWindow.h
Mercury2/src/X11Window.cpp
Modified: Mercury2/modules/Cu2.cpp
===================================================================
--- Mercury2/modules/Cu2.cpp 2010-01-11 08:43:17 UTC (rev 650)
+++ Mercury2/modules/Cu2.cpp 2010-01-11 19:24:25 UTC (rev 651)
@@ -241,6 +241,9 @@
///////////////////////////////////////COPPER 2 ROOT///////////////////////////////////////
+
+MVRefBool Cu2Root::CursorGrabbed( "Input.CursorGrabbed" );
+
Cu2Root::Cu2Root()
{
g_pCurrentInstance = this;
@@ -255,15 +258,14 @@
void Cu2Root::SetHidden( bool bHide )
{
- MercuryWindow::GetCurrentWindow()->SetGrabbedMouseMode( bHide );
-
+ CursorGrabbed.Set( bHide );
MercuryNode::SetHidden( bHide );
}
void Cu2Root::LoadFromXML(const XMLNode& node)
{
Cu2Element::LoadFromXML( node );
- MercuryWindow::GetCurrentWindow()->SetGrabbedMouseMode( IsHidden() );
+ CursorGrabbed.Set( IsHidden() );
}
Modified: Mercury2/modules/Cu2.h
===================================================================
--- Mercury2/modules/Cu2.h 2010-01-11 08:43:17 UTC (rev 650)
+++ Mercury2/modules/Cu2.h 2010-01-11 19:24:25 UTC (rev 651)
@@ -2,6 +2,7 @@
#define _CU2_H
#include <TransformNode.h>
+#include <MercuryValue.h>
///All the mouse actions Cu2 can transmit.
enum Cu2Action
@@ -133,6 +134,8 @@
void HandleMouseInput(const MessageData& data);
void HandleKeyboardInput(const MessageData& data);
+ static MVRefBool CursorGrabbed;
+
GENRTTI( Cu2Root );
private:
static Cu2Root * g_pCurrentInstance;
Modified: Mercury2/src/Camera.cpp
===================================================================
--- Mercury2/src/Camera.cpp 2010-01-11 08:43:17 UTC (rev 650)
+++ Mercury2/src/Camera.cpp 2010-01-11 19:24:25 UTC (rev 651)
@@ -5,6 +5,8 @@
#include <Shader.h>
+MVRefBool CameraNode::CursorGrabbed( "Input.CursorGrabbed" );
+
REGISTER_NODE_TYPE(CameraNode);
CameraNode::CameraNode()
@@ -82,7 +84,11 @@
void CameraNode::HandleMouseInput(const MessageData& data)
{
const MouseInput& m( dynamic_cast<const MouseInput&>( data ) );
-
+
+ //First find out if cursor is grabbed. If it isn't then we shouldn't be responding to the input.
+ if( !CursorGrabbed.Get() )
+ return;
+
m_y += m.dy/1200.0f;
m_x += m.dx/1200.0f;
Modified: Mercury2/src/Camera.h
===================================================================
--- Mercury2/src/Camera.h 2010-01-11 08:43:17 UTC (rev 650)
+++ Mercury2/src/Camera.h 2010-01-11 19:24:25 UTC (rev 651)
@@ -2,6 +2,7 @@
#define CAMERA_H
#include <TransformNode.h>
+#include <MercuryValue.h>
#include <MQuaternion.h>
class CameraNode : public TransformNode
@@ -19,6 +20,8 @@
GENRTTI(CameraNode);
private:
+ static MVRefBool CursorGrabbed;
+
MercuryVertex m_origionalPosition;
MercuryVector m_lookAt;
float m_x, m_y;
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2010-01-11 08:43:17 UTC (rev 650)
+++ Mercury2/src/Mercury2.cpp 2010-01-11 19:24:25 UTC (rev 651)
@@ -211,12 +211,12 @@
public:
TestMouse()
{
- MESSAGEMAN.GetValue( "Input.CursorDeltaX" )->AttachModifyDelegate( (ValueDelegate)&TestMouse::ChangeX, (MessageHandler*)this );
+ MESSAGEMAN.GetValue( "Input.CursorGrabbed" )->AttachModifyDelegate( (ValueDelegate)&TestMouse::ChangeX, (MessageHandler*)this );
}
void ChangeX( MValue * v )
{
- printf( "Changed: %f\n", v->GetFloat() );
+ printf( "Changed: %d\n", v->GetBool() );
}
} TM;
///XXXXXXX REMOVE THIS CODE BEFORE ANY RELEASE XXXXXXXXXXx
Modified: Mercury2/src/MercuryInput.cpp
===================================================================
--- Mercury2/src/MercuryInput.cpp 2010-01-11 08:43:17 UTC (rev 650)
+++ Mercury2/src/MercuryInput.cpp 2010-01-11 19:24:25 UTC (rev 651)
@@ -1,8 +1,9 @@
#include <MercuryInput.h>
#include <MercuryMessageManager.h>
-MVRefFloat GlobalMouseX_Set( "Input.CursorDeltaX" );
-MVRefFloat GlobalMouseY_Set( "Input.CursorDeltaY" );
+MVRefFloat GlobalMouseX_Set( "Input.CursorX" );
+MVRefFloat GlobalMouseY_Set( "Input.CursorY" );
+MVRefInt GlobalMouseB_Set( "Input.CursorButtons" );
MouseInput::MouseInput()
:MessageData(), dx(0), dy(0)
@@ -26,6 +27,7 @@
GlobalMouseX_Set.Set( dx );
GlobalMouseY_Set.Set( dy );
+ GlobalMouseB_Set.Set( currentButtonMasks.data );
POST_MESSAGE( INPUTEVENT_MOUSE, mi, 0 );
}
Modified: Mercury2/src/MercuryValue.h
===================================================================
--- Mercury2/src/MercuryValue.h 2010-01-11 08:43:17 UTC (rev 650)
+++ Mercury2/src/MercuryValue.h 2010-01-11 19:24:25 UTC (rev 651)
@@ -3,6 +3,8 @@
#include <MSemaphore.h>
+class MessageHandler;
+
///Types for the values
enum MVType
{
@@ -160,6 +162,17 @@
void Set( int iv ) { mv->SetInt( iv ); }
};
+///Value Reference for Bool objects.
+class MVRefBool : public MVRefBase
+{
+public:
+ MVRefBool( MValue * m ) : MVRefBase( m ) { }
+ MVRefBool( const MString & p ) : MVRefBase( p ) { }
+
+ int Get() { return mv->GetBool(); }
+ void Set( int iv ) { mv->SetBool( iv ); }
+};
+
///Value Reference for Float objects.
class MVRefFloat : public MVRefBase
{
Modified: Mercury2/src/MercuryWindow.cpp
===================================================================
--- Mercury2/src/MercuryWindow.cpp 2010-01-11 08:43:17 UTC (rev 650)
+++ Mercury2/src/MercuryWindow.cpp 2010-01-11 19:24:25 UTC (rev 651)
@@ -1,9 +1,11 @@
#include "MercuryWindow.h"
+#include "MercuryMessageManager.h"
MercuryWindow::MercuryWindow(const MString& title, int width, int height, int bits, int depthBits, bool fullscreen)
:m_title(title), m_width(width), m_height(height), m_bits(bits), m_depthBits(depthBits), m_fullscreen(fullscreen),
- m_bGrabbed(true),m_iLastMouseX(0),m_iLastMouseY(0),m_inFocus(false)
+ m_iLastMouseX(0),m_iLastMouseY(0),m_inFocus(false)
{
+ MESSAGEMAN.GetValue( "Input.CursorGrabbed" )->SetBool( true );
}
MercuryWindow::~MercuryWindow()
Modified: Mercury2/src/MercuryWindow.h
===================================================================
--- Mercury2/src/MercuryWindow.h 2010-01-11 08:43:17 UTC (rev 650)
+++ Mercury2/src/MercuryWindow.h 2010-01-11 19:24:25 UTC (rev 651)
@@ -32,9 +32,6 @@
inline int Width() const { return m_width; }
inline int Height() const { return m_height; }
- void SetGrabbedMouseMode( bool bGrabbed ) { m_bGrabbed = bGrabbed; }
- bool GetGrabbedMouseMode( ) { return m_bGrabbed; }
-
inline bool InFocus() const { return m_inFocus; }
protected:
@@ -45,7 +42,6 @@
int m_width, m_height;
uint8_t m_bits, m_depthBits;
bool m_fullscreen;
- bool m_bGrabbed;
int m_iLastMouseX;
int m_iLastMouseY;
Modified: Mercury2/src/X11Window.cpp
===================================================================
--- Mercury2/src/X11Window.cpp 2010-01-11 08:43:17 UTC (rev 650)
+++ Mercury2/src/X11Window.cpp 2010-01-11 19:24:25 UTC (rev 651)
@@ -11,6 +11,8 @@
#define MOUSE_BTN_SCROLL_UP 4
#define MOUSE_BTN_SCROLL_DOWN 5
+MVRefBool GlobalMouseGrabbed_Set( "Input.CursorGrabbed" );
+
// Use X11_MASK(MOUSE_BTN_SCROLL_UP) to generate the token Button4Mask
#define X11_MASK(x) _X11_MASK(x)
// Sigh... second #define needed, because otherwise x doesn't get evaluated.
@@ -266,7 +268,7 @@
{
//XFocusChangeEvent*e = (XFocusChangeEvent*)&event;
m_inFocus = (event.type == FocusIn);
- if (m_inFocus && m_bGrabbed ) XWarpPointer(m_display, None, m_window, 0,0,0,0,m_width/2,m_height/2);
+ if (m_inFocus && GlobalMouseGrabbed_Set.Get() ) XWarpPointer(m_display, None, m_window, 0,0,0,0,m_width/2,m_height/2);
break;
}
}
@@ -317,7 +319,7 @@
center = e->state & X11_MASK(MOUSE_BTN_CENTER);
su = e->state & X11_MASK(MOUSE_BTN_SCROLL_UP);
sd = e->state & X11_MASK(MOUSE_BTN_SCROLL_DOWN);
- if( m_bGrabbed )
+ if( GlobalMouseGrabbed_Set.Get() )
{
x = m_width/2 - e->x;
y = m_height/2 - e->y;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2010-01-11 08:43:24
|
Revision: 650
http://hgengine.svn.sourceforge.net/hgengine/?rev=650&view=rev
Author: cnlohr
Date: 2010-01-11 08:43:17 +0000 (Mon, 11 Jan 2010)
Log Message:
-----------
add testing code in Mercury2.cpp for this variable thing
Modified Paths:
--------------
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryInput.cpp
Mercury2/src/MercuryMessageManager.cpp
Mercury2/src/MercuryMessageManager.h
Mercury2/src/MercuryValue.cpp
Mercury2/src/MercuryValue.h
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2010-01-11 08:01:21 UTC (rev 649)
+++ Mercury2/src/Mercury2.cpp 2010-01-11 08:43:17 UTC (rev 650)
@@ -199,8 +199,30 @@
// printf("Render wait %%%f\n", (RenderWaited/double(totalWaited))*100.0f);
return 0;
-}
+}
+
+
+
+
+
+///XXXXXXXX STUB CODE XXXXXXXXXXX THIS CODE SHOULD BE REMOVED AS SOON AS TESTING OF THE VARIABLE SYSTEM IS COMPLETE
+class TestMouse
+{
+public:
+ TestMouse()
+ {
+ MESSAGEMAN.GetValue( "Input.CursorDeltaX" )->AttachModifyDelegate( (ValueDelegate)&TestMouse::ChangeX, (MessageHandler*)this );
+ }
+
+ void ChangeX( MValue * v )
+ {
+ printf( "Changed: %f\n", v->GetFloat() );
+ }
+} TM;
+///XXXXXXX REMOVE THIS CODE BEFORE ANY RELEASE XXXXXXXXXXx
+
+
/* Copyright (c) 2008, Joshua Allen
* All rights reserved.
*
Modified: Mercury2/src/MercuryInput.cpp
===================================================================
--- Mercury2/src/MercuryInput.cpp 2010-01-11 08:01:21 UTC (rev 649)
+++ Mercury2/src/MercuryInput.cpp 2010-01-11 08:43:17 UTC (rev 650)
@@ -1,6 +1,9 @@
#include <MercuryInput.h>
#include <MercuryMessageManager.h>
+MVRefFloat GlobalMouseX_Set( "Input.CursorDeltaX" );
+MVRefFloat GlobalMouseY_Set( "Input.CursorDeltaY" );
+
MouseInput::MouseInput()
:MessageData(), dx(0), dy(0)
{
@@ -20,7 +23,10 @@
buttons.scrolldown = scrollDownButton;
mi->buttons = buttons;
currentButtonMasks = buttons;
-
+
+ GlobalMouseX_Set.Set( dx );
+ GlobalMouseY_Set.Set( dy );
+
POST_MESSAGE( INPUTEVENT_MOUSE, mi, 0 );
}
Modified: Mercury2/src/MercuryMessageManager.cpp
===================================================================
--- Mercury2/src/MercuryMessageManager.cpp 2010-01-11 08:01:21 UTC (rev 649)
+++ Mercury2/src/MercuryMessageManager.cpp 2010-01-11 08:43:17 UTC (rev 650)
@@ -147,6 +147,17 @@
return mh;
}
+MValue * MercuryMessageManager::GetValue( const MString & sVariableName )
+{
+ MValue * v = m_allValues.get( sVariableName );
+ if( !v )
+ {
+ v = &m_allValues[sVariableName];
+ v->SetReferences( 1 );
+ }
+ return v;
+}
+
MercuryMessageManager& MercuryMessageManager::GetInstance()
{
static MercuryMessageManager *instance = NULL;
Modified: Mercury2/src/MercuryMessageManager.h
===================================================================
--- Mercury2/src/MercuryMessageManager.h 2010-01-11 08:01:21 UTC (rev 649)
+++ Mercury2/src/MercuryMessageManager.h 2010-01-11 08:43:17 UTC (rev 650)
@@ -46,7 +46,9 @@
void RegisterForMessage(const MString& message, MessageHandler* ptr, MessageDelegate d = 0 );
void UnRegisterForMessage(const MString& message, MessageHandler* ptr);
-
+
+ MValue * GetValue( const MString & sVariableName );
+
static MercuryMessageManager& GetInstance();
private:
void FireOffMessage( const MessageHolder & message );
@@ -63,7 +65,8 @@
};
MHash< std::list< MessagePair > > m_messageRecipients;
-
+ MHash< MValue > m_allValues; //Careful - these cannot be deleted.
+
// MercuryMutex m_lock;
MSemaphore m_queueLock;
MSemaphore m_recipientLock;
Modified: Mercury2/src/MercuryValue.cpp
===================================================================
--- Mercury2/src/MercuryValue.cpp 2010-01-11 08:01:21 UTC (rev 649)
+++ Mercury2/src/MercuryValue.cpp 2010-01-11 08:43:17 UTC (rev 650)
@@ -43,6 +43,10 @@
+MValue::MValue( ) : m_References( 0 ), m_CurType( TYPE_UNDEF ), DLDelete( 0 ), DLModify( 0 )
+{
+ m_Data.v = 0;
+}
MValue::MValue( MVType t ) : m_References( 0 ), m_CurType( t ), DLDelete( 0 ), DLModify( 0 )
{
@@ -113,3 +117,43 @@
}
}
+MVRefBase::MVRefBase(const MString & sPath)
+{
+ mv = MESSAGEMAN.GetValue( sPath );
+ MSemaphoreLock( &mv->m_Sema );
+ mv->m_References++;
+}
+
+
+/****************************************************************************
+ * Copyright (C) 2010 by 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. *
+ ***************************************************************************/
+
Modified: Mercury2/src/MercuryValue.h
===================================================================
--- Mercury2/src/MercuryValue.h 2010-01-11 08:01:21 UTC (rev 649)
+++ Mercury2/src/MercuryValue.h 2010-01-11 08:43:17 UTC (rev 650)
@@ -42,7 +42,7 @@
class MValue
{
public:
-
+ MValue();
MValue( MVType t );
~MValue();
@@ -80,6 +80,15 @@
}
MVType GetType() { return m_CurType; }
+
+ void AttachModifyDelegate( DeletionNotifier NotifyFunction, MessageHandler * NotifyObject )
+ {
+ DelegateNotifierList * d = new DelegateNotifierList( NotifyFunction, NotifyObject );
+ d->Next = DLModify;
+ DLModify = d;
+ }
+
+ void SetReferences( short RefCount ) { m_References = RefCount; }
private:
//Conv functions are not thread protected - this is because the caller of these functions should be.
int ConvInt();
@@ -144,6 +153,9 @@
class MVRefInt : public MVRefBase
{
public:
+ MVRefInt( MValue * m ) : MVRefBase( m ) { }
+ MVRefInt( const MString & p ) : MVRefBase( p ) { }
+
int Get() { return mv->GetInt(); }
void Set( int iv ) { mv->SetInt( iv ); }
};
@@ -152,6 +164,9 @@
class MVRefFloat : public MVRefBase
{
public:
+ MVRefFloat( MValue * m ) : MVRefBase( m ) { }
+ MVRefFloat( const MString & p ) : MVRefBase( p ) { }
+
float Get() { return mv->GetFloat(); }
void Set( float fv ) { mv->SetFloat( fv ); }
};
@@ -160,6 +175,9 @@
class MVRefString : public MVRefBase
{
public:
+ MVRefString( MValue * m ) : MVRefBase( m ) { }
+ MVRefString( const MString & p ) : MVRefBase( p ) { }
+
const MString & Get() { return mv->GetString(); }
void Set( const MString & sv ) { mv->SetString( sv ); }
};
@@ -168,6 +186,9 @@
class MVRefPtr : public MVRefBase
{
public:
+ MVRefPtr( MValue * m ) : MVRefBase( m ) { }
+ MVRefPtr( const MString & p ) : MVRefBase( p ) { }
+
T * Get() {
return (T*)mv->GetPtr();
}
@@ -208,3 +229,4 @@
* (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: <cn...@us...> - 2010-01-11 08:01:28
|
Revision: 649
http://hgengine.svn.sourceforge.net/hgengine/?rev=649&view=rev
Author: cnlohr
Date: 2010-01-11 08:01:21 +0000 (Mon, 11 Jan 2010)
Log Message:
-----------
add the MercuryValue thing - kind of dirty at the moment, in process of cleaning up.
Modified Paths:
--------------
Mercury2/adv_set.c
Mercury2/src/MercuryMessageManager.h
Added Paths:
-----------
Mercury2/src/MercuryValue.cpp
Mercury2/src/MercuryValue.h
Modified: Mercury2/adv_set.c
===================================================================
--- Mercury2/adv_set.c 2010-01-10 22:27:01 UTC (rev 648)
+++ Mercury2/adv_set.c 2010-01-11 08:01:21 UTC (rev 649)
@@ -15,7 +15,7 @@
src/GLHelpers.cpp src/FullscreenQuad.cpp src/MercuryNamedResource.cpp src/MercuryPrefs.cpp \
src/MercuryTheme.cpp src/Orthographic.cpp src/Light.cpp src/RenderDeferredLights.cpp \
src/MercuryLog.cpp src/MercuryCTA.cpp src/DataTypes/MTriangle.cpp src/StateChanger.cpp \
- src/MercurySound.cpp src/MercurySoundSourceRAM.cpp "
+ src/MercurySound.cpp src/MercurySoundSourceRAM.cpp src/MercuryValue.cpp"
SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \
src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp"
Modified: Mercury2/src/MercuryMessageManager.h
===================================================================
--- Mercury2/src/MercuryMessageManager.h 2010-01-10 22:27:01 UTC (rev 648)
+++ Mercury2/src/MercuryMessageManager.h 2010-01-11 08:01:21 UTC (rev 649)
@@ -11,8 +11,8 @@
#include <MercuryUtil.h>
#include <Mint.h>
#include <MAutoPtr.h>
-
#include <MSemaphore.h>
+#include <MercuryValue.h>
class MessageHolder : public RefBase
{
Added: Mercury2/src/MercuryValue.cpp
===================================================================
--- Mercury2/src/MercuryValue.cpp (rev 0)
+++ Mercury2/src/MercuryValue.cpp 2010-01-11 08:01:21 UTC (rev 649)
@@ -0,0 +1,115 @@
+#include <MercuryMessageManager.h>
+#include <MercuryValue.h>
+#include <MessageHandler.h>
+
+
+DelegateNotifierList::DelegateNotifierList( DeletionNotifier nf, MessageHandler * no ) :
+ NotifyFunction( nf ), NotifyObject( no ), Next( 0 )
+{
+}
+
+DelegateNotifierList::~DelegateNotifierList()
+{
+ SAFE_DELETE( Next );
+}
+
+void DelegateNotifierList::AddNotifier( DeletionNotifier nf, MessageHandler * no )
+{
+ DelegateNotifierList * nn = new DelegateNotifierList( nf, no );
+ nn->Next = Next;
+ Next = nn;
+}
+
+void DelegateNotifierList::DelNotifier( DeletionNotifier nf, MessageHandler * no, DelegateNotifierList * & ths )
+{
+ if( nf == NotifyFunction && no == NotifyObject )
+ {
+ ths = Next;
+ delete this;
+ return;
+ }
+ if( Next )
+ Next->DelNotifier( nf, no, Next );
+}
+
+void DelegateNotifierList::Notify( MValue * v )
+{
+ (NotifyObject->*NotifyFunction)( v );
+ if( Next )
+ Next->Notify( v );
+}
+
+
+
+
+
+
+MValue::MValue( MVType t ) : m_References( 0 ), m_CurType( t ), DLDelete( 0 ), DLModify( 0 )
+{
+ m_Data.v = 0;
+}
+
+MValue::~MValue()
+{
+ Cleanup();
+ SAFE_DELETE( DLModify );
+ SAFE_DELETE( DLDelete );
+}
+
+void MValue::Cleanup()
+{
+ if( DLDelete )
+ DLDelete->Notify( this );
+ SAFE_DELETE( DLDelete );
+
+ if( m_CurType == TYPE_STRING )
+ SAFE_DELETE( m_Data.dataS );
+}
+
+int MValue::ConvInt()
+{
+ switch( m_CurType )
+ {
+ case TYPE_INT: return m_Data.l;
+ case TYPE_FLOAT: return m_Data.f;
+ case TYPE_STRING: return StrToInt(*m_Data.dataS);
+ default: return 0;
+ }
+}
+
+float MValue::ConvFloat()
+{
+ switch( m_CurType )
+ {
+ case TYPE_INT: return m_Data.l;
+ case TYPE_FLOAT: return m_Data.f;
+ case TYPE_STRING: return StrToFloat(*m_Data.dataS);
+ default: return 0;
+ }
+}
+
+
+const MString & MValue::ConvString()
+{
+ static const MString NILVAL = "(NIL)";
+ switch( m_CurType )
+ {
+ case TYPE_STRING: return *m_Data.dataS;
+ case TYPE_INT: ssprintf( "%d", m_Data.l );
+ case TYPE_FLOAT: ssprintf( "%f", m_Data.f );
+ case TYPE_PTR: ssprintf( "%p", m_Data.v );
+ default: return NILVAL;
+ }
+}
+
+bool MValue::ConvBool()
+{
+ switch( m_CurType )
+ {
+ case TYPE_INT: return m_Data.l != 0;
+ case TYPE_FLOAT: return m_Data.f != 0;
+ case TYPE_STRING: return StrToBool(*m_Data.dataS);
+ default: return 0;
+ }
+}
+
Added: Mercury2/src/MercuryValue.h
===================================================================
--- Mercury2/src/MercuryValue.h (rev 0)
+++ Mercury2/src/MercuryValue.h 2010-01-11 08:01:21 UTC (rev 649)
@@ -0,0 +1,210 @@
+#ifndef _MERCURY_VALUE_H
+#define _MERCURY_VALUE_H
+
+#include <MSemaphore.h>
+
+///Types for the values
+enum MVType
+{
+ TYPE_UNDEF = 0,
+ TYPE_STRING,
+ TYPE_INT,
+ TYPE_FLOAT,
+ TYPE_PTR,
+};
+
+class MValue;
+
+///Delegate for changes to MValues
+typedef void (MessageHandler::*ValueDelegate)( MValue * );
+
+///Delegate to notify an object that it should delete itself
+typedef void (MessageHandler::*DeletionNotifier)( MValue * );
+
+///Delegate List Notifier. This contains a list of delegates to get called back when an event happens.
+class DelegateNotifierList
+{
+public:
+ DelegateNotifierList( DeletionNotifier NotifyFunction, MessageHandler * NotifyObject );
+ ~DelegateNotifierList();
+
+ void AddNotifier( DeletionNotifier NotifyFunction, MessageHandler * NotifyObject );
+ void DelNotifier( DeletionNotifier NotifyFunction, MessageHandler * NotifyObject, DelegateNotifierList * & ths );
+ void Notify( MValue * v );
+
+ DeletionNotifier NotifyFunction;
+ MessageHandler * NotifyObject;
+ DelegateNotifierList * Next;
+};
+
+///Variable for general purpose use - generally global scope or passed around. Similar to PSElement.
+/** You usually don't want to make and delete a lot of these. It's best to keep them around and use references. */
+class MValue
+{
+public:
+
+ MValue( MVType t );
+ ~MValue();
+
+ int GetInt() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_INT)?m_Data.l:ConvInt(); }
+ float GetFloat() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_FLOAT)?m_Data.f:ConvFloat(); }
+ const MString & GetString() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_STRING)?*m_Data.dataS:ConvString(); }
+ bool GetBool() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_INT)?m_Data.l:ConvBool(); }
+ void * GetPtr() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_PTR)?m_Data.v:0; }
+
+ void SetInt( int iv ) { MSemaphoreLock( &this->m_Sema ); Cleanup(); m_Data.l = iv; m_CurType = TYPE_INT; Notify();}
+ void SetFloat( float iv ) { MSemaphoreLock( &this->m_Sema ); Cleanup(); m_Data.f = iv; m_CurType = TYPE_FLOAT; Notify(); }
+ void SetString( const MString & iv )
+ {
+ MSemaphoreLock( &this->m_Sema );
+ if( m_CurType != TYPE_STRING )
+ {
+ Cleanup();
+ m_Data.dataS = new MString( iv );
+ m_CurType = TYPE_STRING;
+ }
+ else
+ (*m_Data.dataS) = iv;
+ Notify();
+ }
+ void SetBool( bool iv ){ MSemaphoreLock( &this->m_Sema ); m_Data.l = iv; m_CurType = TYPE_INT; Notify(); }
+ void SetPtr( void * ptr, DelegateNotifierList * dl )
+ {
+ MSemaphoreLock( &this->m_Sema );
+ Cleanup();
+ SAFE_DELETE( DLDelete );
+ DLDelete = dl;
+ m_CurType = TYPE_PTR;
+ m_Data.v = ptr;
+ Notify();
+ }
+
+ MVType GetType() { return m_CurType; }
+private:
+ //Conv functions are not thread protected - this is because the caller of these functions should be.
+ int ConvInt();
+ float ConvFloat();
+ const MString & ConvString();
+ bool ConvBool();
+
+ //Cleanup (to be done when object is deleted or switching types)
+ void Cleanup();
+
+ //A change happened.
+ void Notify() { if( DLModify ) DLModify->Notify( this ); }
+
+ unsigned short m_References;
+ MVType m_CurType : 8;
+
+ union ParmData
+ {
+ float f;
+ int l;
+ void * v;
+ MString * dataS;
+ } m_Data;
+
+ //XXX: Performance warning: One could simply operate on these
+ //values atomically. A full extra semaphore isn't necessairly
+ //needed for everything
+ MSemaphore m_Sema;
+
+
+ DelegateNotifierList * DLDelete;
+ DelegateNotifierList * DLModify;
+
+ friend class MVRefBase;
+};
+
+//Sadly for a number of reasons, these cannot be templated or macro'd... Well, macro'd cleanly.
+
+///Reference base - don't use this.
+/** Be sure not to let anything here become virtual otherwise there will be a slow down potentially. */
+class MVRefBase
+{
+public:
+ MVRefBase(MValue * m) : mv(m) { MSemaphoreLock( &mv->m_Sema ); mv->m_References++; }
+ MVRefBase(const MString & sPath); //Special - get values from MESSAGEMAN
+ ~MVRefBase() {
+ //If out of references, bail.
+ mv->m_Sema.Wait();
+ mv->m_References--;
+ if( mv->m_References <= 0 )
+ {
+ delete mv;
+ return;
+ }
+ mv->m_Sema.UnLock();
+ }
+protected:
+ MValue * mv;
+};
+
+///Value Reference for Int objects.
+class MVRefInt : public MVRefBase
+{
+public:
+ int Get() { return mv->GetInt(); }
+ void Set( int iv ) { mv->SetInt( iv ); }
+};
+
+///Value Reference for Float objects.
+class MVRefFloat : public MVRefBase
+{
+public:
+ float Get() { return mv->GetFloat(); }
+ void Set( float fv ) { mv->SetFloat( fv ); }
+};
+
+///Value Reference for Float objects.
+class MVRefString : public MVRefBase
+{
+public:
+ const MString & Get() { return mv->GetString(); }
+ void Set( const MString & sv ) { mv->SetString( sv ); }
+};
+
+template< typename T >
+class MVRefPtr : public MVRefBase
+{
+public:
+ T * Get() {
+ return (T*)mv->GetPtr();
+ }
+ void Set( T* iv, DelegateNotifierList * del = 0 ) { mv->SetPtr( iv, del ); }
+};
+
+#endif
+
+
+/****************************************************************************
+ * Copyright (C) 2010 by 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: <cn...@us...> - 2010-01-10 22:27:09
|
Revision: 648
http://hgengine.svn.sourceforge.net/hgengine/?rev=648&view=rev
Author: cnlohr
Date: 2010-01-10 22:27:01 +0000 (Sun, 10 Jan 2010)
Log Message:
-----------
fix warnings
Modified Paths:
--------------
Mercury2/src/GLHelpers.cpp
Mercury2/src/MercuryAsset.cpp
Mercury2/src/MercuryBacktrace.c
Mercury2/src/MercuryFileDriverDirect.cpp
Mercury2/src/MercuryLog.cpp
Mercury2/src/MercurySoundDriverALSA.cpp
Mercury2/src/MercurySoundSourceRAM.cpp
Mercury2/src/MercurySoundSourceVorbis.cpp
Mercury2/src/MercuryUtil.cpp
Mercury2/src/StateChanger.cpp
Modified: Mercury2/src/GLHelpers.cpp
===================================================================
--- Mercury2/src/GLHelpers.cpp 2010-01-10 22:13:44 UTC (rev 647)
+++ Mercury2/src/GLHelpers.cpp 2010-01-10 22:27:01 UTC (rev 648)
@@ -59,7 +59,7 @@
MercuryVertex pointFromScreenLoc(int screen_x, int screen_y, float fForceDepth)
{
- GLfloat winX, winY, winZ;
+ GLfloat winX, winY;
GLdouble mouseX = 0, mouseY = 0, mouseZ = 0;
GLint viewport[4];
GLdouble modelview[16];
@@ -93,7 +93,7 @@
void CameraPointAndRay(int screen_x, int screen_y, MercuryVertex & p, MercuryVertex & r)
{
- GLfloat winX, winY, winZ;
+ GLfloat winX, winY;
GLdouble dox = 0, doy = 0, doz = 0;
GLint viewport[4];
GLdouble modelview[16];
Modified: Mercury2/src/MercuryAsset.cpp
===================================================================
--- Mercury2/src/MercuryAsset.cpp 2010-01-10 22:13:44 UTC (rev 647)
+++ Mercury2/src/MercuryAsset.cpp 2010-01-10 22:27:01 UTC (rev 648)
@@ -6,8 +6,7 @@
extern bool DOOCCLUSIONCULL;
MercuryAsset::MercuryAsset( const MString & key, bool bInstanced )
- :m_isInstanced(bInstanced), m_boundingVolume(NULL),
- m_path( key ), m_loadState(NONE), m_ignoreCull(false), m_iPasses( DEFAULT_PASSES ), slType( 0 )
+ :slType( 0 ), m_isInstanced(bInstanced), m_boundingVolume(NULL), m_path( key ), m_loadState(NONE), m_ignoreCull(false), m_iPasses( DEFAULT_PASSES )
{
}
Modified: Mercury2/src/MercuryBacktrace.c
===================================================================
--- Mercury2/src/MercuryBacktrace.c 2010-01-10 22:13:44 UTC (rev 647)
+++ Mercury2/src/MercuryBacktrace.c 2010-01-10 22:27:01 UTC (rev 648)
@@ -208,7 +208,11 @@
#else
sprintf( execline, "addr2line -fC -e %s 0x%lx 1>&%d", file, (unsigned long)offset, fds[1] );
#endif
- system( execline );
+ if( system( execline ) != 0 )
+ {
+ printf( "Failed to execute backtrace app. Command line:\"%s\".", execline );
+ return 0;
+ }
readbytes = read( fds[0], buffer, 1024 );
if( readbytes + 1 >= maxlen )
@@ -336,7 +340,10 @@
if( DBGSetup )
return;
DBGSetup = 1;
- pipe( fds );
+ if( pipe( fds ) != 0 )
+ {
+ printf( "Warning: Could not pipe for backtrace.\n" );
+ }
#ifdef _CMAC
sprintf( execline, "atos 2>&%d", fds[0] );
Modified: Mercury2/src/MercuryFileDriverDirect.cpp
===================================================================
--- Mercury2/src/MercuryFileDriverDirect.cpp 2010-01-10 22:13:44 UTC (rev 647)
+++ Mercury2/src/MercuryFileDriverDirect.cpp 2010-01-10 22:27:01 UTC (rev 648)
@@ -237,7 +237,10 @@
return;
}
*path_end = 0;
- chdir( buffer );
+ if( chdir( buffer ) != 0 )
+ {
+ fprintf( stderr, "WARNING: Could not change path of executable to \"%s\"\n", buffer );
+ }
#endif
#endif
}
Modified: Mercury2/src/MercuryLog.cpp
===================================================================
--- Mercury2/src/MercuryLog.cpp 2010-01-10 22:13:44 UTC (rev 647)
+++ Mercury2/src/MercuryLog.cpp 2010-01-10 22:27:01 UTC (rev 648)
@@ -13,6 +13,7 @@
log->WriteQueue();
msleep(100); //10x/sec
}
+ return 0;
}
MercuryLog::MercuryLog()
Modified: Mercury2/src/MercurySoundDriverALSA.cpp
===================================================================
--- Mercury2/src/MercurySoundDriverALSA.cpp 2010-01-10 22:13:44 UTC (rev 647)
+++ Mercury2/src/MercurySoundDriverALSA.cpp 2010-01-10 22:27:01 UTC (rev 648)
@@ -207,7 +207,7 @@
SOUNDMAN->FillBuffer( ibuf, nrframes );
- for( unsigned i = 0; i < nrframes; ++i )
+ for( int i = 0; i < nrframes; ++i )
{
float fi = ibuf[i*2+0];
float fb = ibuf[i*2+1];
Modified: Mercury2/src/MercurySoundSourceRAM.cpp
===================================================================
--- Mercury2/src/MercurySoundSourceRAM.cpp 2010-01-10 22:13:44 UTC (rev 647)
+++ Mercury2/src/MercurySoundSourceRAM.cpp 2010-01-10 22:27:01 UTC (rev 648)
@@ -6,8 +6,6 @@
void MercurySoundSourceRAM::FillBuffer( float * cBufferToFill, int iCount )
{
- int i;
-
int iOffset = 0;
if( m_iSampleHold > 0 )
@@ -28,7 +26,7 @@
int placeBytes = m_iSoundPlace* MercurySoundManager::iChannels;
- for( unsigned i = iOffset; i < iCopyFrames * MercurySoundManager::iChannels; i++ )
+ for( int i = iOffset; i < iCopyFrames * MercurySoundManager::iChannels; i++ )
{
cBufferToFill[i] = m_Sound->fSound[placeBytes+i];
}
Modified: Mercury2/src/MercurySoundSourceVorbis.cpp
===================================================================
--- Mercury2/src/MercurySoundSourceVorbis.cpp 2010-01-10 22:13:44 UTC (rev 647)
+++ Mercury2/src/MercurySoundSourceVorbis.cpp 2010-01-10 22:27:01 UTC (rev 648)
@@ -118,7 +118,7 @@
REGISTER_SOUND_SOURCE( MercurySoundSourceVorbis, "Vorbis" );
MercurySoundSourceVorbis::MercurySoundSourceVorbis( MercurySoundSource * chain ) :
- MercurySoundSource( chain ), iBufferSize( 32768 ), iBufferLoad(1), iBufferPlay(0)
+ MercurySoundSource( chain ), iBufferSize( 32768 ), iBufferPlay(0), iBufferLoad(1)
{
iBuffer = (short*)malloc( sizeof( short ) * iBufferSize * 2 );
}
@@ -134,7 +134,7 @@
bool MercurySoundSourceVorbis::Load( const MString & sDescriptor )
{
MAutoPtr< HGRawSound > r;
- MAutoPtr< HGRawSound > * g;
+// MAutoPtr< HGRawSound > * g;
m_File = FILEMAN.Open( sDescriptor );
@@ -148,12 +148,13 @@
ov_open_callbacks( m_File, vorbisFile, NULL, 0, vorbisCallbacks );
- vorbis_info* info = ov_info(vorbisFile, -1);
+// vorbis_info* info = ov_info(vorbisFile, -1);
// unsigned VorbisChannels = info->channels;
// unsigned VorbisSamplerate = info->rate;
+
unsigned VorbisSamples = ov_pcm_total( vorbisFile, 0 );
- unsigned Vorbisbytes_read;
+// unsigned Vorbisbytes_read;
if( VorbisSamples <= 0 )
{
@@ -169,7 +170,7 @@
void MercurySoundSourceVorbis::FillBuffer( float * cBufferToFill, int iCount )
{
//Don't worry our circular queue is threadsafe.
- for( unsigned i = 0; i < iCount; i++ )
+ for( int i = 0; i < iCount; i++ )
{
if( PlayLeft() <= 2 ) break;
cBufferToFill[i*2+0] = float(iBuffer[iBufferPlay*2+0])/32768.;
Modified: Mercury2/src/MercuryUtil.cpp
===================================================================
--- Mercury2/src/MercuryUtil.cpp 2010-01-10 22:13:44 UTC (rev 647)
+++ Mercury2/src/MercuryUtil.cpp 2010-01-10 22:27:01 UTC (rev 648)
@@ -234,6 +234,7 @@
if( !f ) return false;
f->Write( data.c_str(), data.length() );
delete f;
+ return true;
}
Modified: Mercury2/src/StateChanger.cpp
===================================================================
--- Mercury2/src/StateChanger.cpp 2010-01-10 22:13:44 UTC (rev 647)
+++ Mercury2/src/StateChanger.cpp 2010-01-10 22:27:01 UTC (rev 648)
@@ -61,7 +61,7 @@
void Stringify( MString & sOut )
{
- sOut = ssprintf( "%f", bEnable );
+ sOut = (bEnable)?"1":"0";
}
void Activate()
@@ -99,7 +99,7 @@
void Stringify( MString & sOut )
{
- sOut = ssprintf( "%f", bEnable );
+ sOut = (bEnable)?"1":"0";
}
void Activate()
@@ -136,7 +136,7 @@
void Stringify( MString & sOut )
{
- sOut = ssprintf( "%f", bEnable );
+ sOut = (bEnable)?"1":"0";
}
void Activate()
@@ -188,6 +188,7 @@
STRTOGL(s, CONSTANT_ALPHA);
STRTOGL(s, ONE_MINUS_CONSTANT_ALPHA);
STRTOGL(s, SRC_ALPHA_SATURATE);
+ return -1;
}
#define GLTOSTR(x,s) case GL_##s: return #s;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2010-01-10 22:13:50
|
Revision: 647
http://hgengine.svn.sourceforge.net/hgengine/?rev=647&view=rev
Author: cnlohr
Date: 2010-01-10 22:13:44 +0000 (Sun, 10 Jan 2010)
Log Message:
-----------
rename Delegate to MessageDelegate since we will have multiple types. Also, add a little bit to Cu2
Modified Paths:
--------------
Mercury2/modules/Cu2.cpp
Mercury2/modules/Cu2.h
Mercury2/src/MercuryMessageManager.cpp
Mercury2/src/MercuryMessageManager.h
Modified: Mercury2/modules/Cu2.cpp
===================================================================
--- Mercury2/modules/Cu2.cpp 2009-12-29 15:52:06 UTC (rev 646)
+++ Mercury2/modules/Cu2.cpp 2010-01-10 22:13:44 UTC (rev 647)
@@ -558,7 +558,16 @@
}
}
+void Cu2Dialog::UpdateSize()
+{
+ if( m_pTitle )
+ {
+ m_pTitle->SetShiftY( GetH() - 18 );
+ m_pTitle->RenderText();
+ }
+}
+
REGISTER_NODE_TYPE(Cu2Dialog);
Modified: Mercury2/modules/Cu2.h
===================================================================
--- Mercury2/modules/Cu2.h 2009-12-29 15:52:06 UTC (rev 646)
+++ Mercury2/modules/Cu2.h 2010-01-10 22:13:44 UTC (rev 647)
@@ -45,6 +45,9 @@
///Called when a key is pressed - down the focus line.
virtual void GetKeypress( int key, bool bDown, bool bRepeat );
+ ///Called whenever the element is resized.
+ virtual void UpdateSize() { }
+
//Below here - you run into functions that are seldom overloaded.
///Handle updating of tab information
@@ -88,7 +91,7 @@
float GetY() { return m_fY; }
///Set Width/Height
- void SetSize( float fW, float fH ) { m_fW = fW; m_fH = fH; }
+ void SetSize( float fW, float fH ) { m_fW = fW; m_fH = fH; UpdateSize(); }
///Set Width
void SetW( float fW ) { m_fW = fW; }
///Set Height
@@ -185,6 +188,7 @@
virtual void Render( const MercuryMatrix& m );
virtual int MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask );
virtual void MouseAction( int x, int y, Cu2Action c, int iWhichButton );
+ virtual void UpdateSize();
void SetText( const MString & sText );
Modified: Mercury2/src/MercuryMessageManager.cpp
===================================================================
--- Mercury2/src/MercuryMessageManager.cpp 2009-12-29 15:52:06 UTC (rev 646)
+++ Mercury2/src/MercuryMessageManager.cpp 2010-01-10 22:13:44 UTC (rev 647)
@@ -94,7 +94,7 @@
}
-void MercuryMessageManager::RegisterForMessage(const MString& message, MessageHandler* ptr, Delegate d )
+void MercuryMessageManager::RegisterForMessage(const MString& message, MessageHandler* ptr, MessageDelegate d )
{
MSemaphoreLock lock(&m_recipientLock);
m_messageRecipients[message].push_back(MessagePair(ptr, d));
Modified: Mercury2/src/MercuryMessageManager.h
===================================================================
--- Mercury2/src/MercuryMessageManager.h 2009-12-29 15:52:06 UTC (rev 646)
+++ Mercury2/src/MercuryMessageManager.h 2010-01-10 22:13:44 UTC (rev 647)
@@ -24,7 +24,7 @@
static bool Compare( void * left, void * right );
};
-typedef void (MessageHandler::*Delegate)(const MessageData&);
+typedef void (MessageHandler::*MessageDelegate)(const MessageData&);
/* This message system uses absolute integer time values to fire off events.
This ensures accuarate firing times while eliminating floating point error.
@@ -44,7 +44,7 @@
void PumpMessages(const uint64_t& currTime);
- void RegisterForMessage(const MString& message, MessageHandler* ptr, Delegate d = 0 );
+ void RegisterForMessage(const MString& message, MessageHandler* ptr, MessageDelegate d = 0 );
void UnRegisterForMessage(const MString& message, MessageHandler* ptr);
static MercuryMessageManager& GetInstance();
@@ -57,9 +57,9 @@
struct MessagePair
{
- MessagePair( MessageHandler * th, Delegate td ) : h(th), d(td) { }
+ MessagePair( MessageHandler * th, MessageDelegate td ) : h(th), d(td) { }
MessageHandler * h;
- Delegate d;
+ MessageDelegate d;
};
MHash< std::list< MessagePair > > m_messageRecipients;
@@ -72,7 +72,7 @@
static InstanceCounter<MercuryMessageManager> MMcounter("MessageManager");
#define MESSAGEMAN MercuryMessageManager::GetInstance()
-#define REGISTER_MESSAGE_WITH_DELEGATE(x, d) MESSAGEMAN.RegisterForMessage(x, this, (Delegate)d)
+#define REGISTER_MESSAGE_WITH_DELEGATE(x, d) MESSAGEMAN.RegisterForMessage(x, this, (MessageDelegate)d)
#define REGISTER_FOR_MESSAGE(x) MESSAGEMAN.RegisterForMessage(x, this)
#define UNREGISTER_FOR_MESSAGE(x) MESSAGEMAN.UnRegisterForMessage(x, this)
#define POST_MESSAGE(x,data,delay) MESSAGEMAN.PostMessage(x, data, delay)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-12-29 15:52:14
|
Revision: 646
http://hgengine.svn.sourceforge.net/hgengine/?rev=646&view=rev
Author: axlecrusher
Date: 2009-12-29 15:52:06 +0000 (Tue, 29 Dec 2009)
Log Message:
-----------
enable writing blend state
Modified Paths:
--------------
Mercury2/src/StateChanger.cpp
Modified: Mercury2/src/StateChanger.cpp
===================================================================
--- Mercury2/src/StateChanger.cpp 2009-12-28 22:26:28 UTC (rev 645)
+++ Mercury2/src/StateChanger.cpp 2009-12-29 15:52:06 UTC (rev 646)
@@ -167,8 +167,7 @@
void Stringify( MString & sOut )
{
- //XXX
-// sOut = ssprintf( "%f", bEnable );
+ sOut = BlendToString(m_src) + "," + BlendToString(m_dest);
}
#define STRTOGL(x,s) if (x==#s) return GL_##s;
@@ -191,6 +190,29 @@
STRTOGL(s, SRC_ALPHA_SATURATE);
}
+ #define GLTOSTR(x,s) case GL_##s: return #s;
+ MString BlendToString(int blend)
+ {
+ switch (blend)
+ {
+ GLTOSTR(blend, ZERO);
+ GLTOSTR(blend, ONE);
+ GLTOSTR(blend, SRC_COLOR);
+ GLTOSTR(blend, ONE_MINUS_SRC_COLOR);
+ GLTOSTR(blend, DST_COLOR);
+ GLTOSTR(blend, ONE_MINUS_DST_COLOR);
+ GLTOSTR(blend, SRC_ALPHA);
+ GLTOSTR(blend, ONE_MINUS_SRC_ALPHA);
+ GLTOSTR(blend, DST_ALPHA);
+ GLTOSTR(blend, ONE_MINUS_DST_ALPHA);
+ GLTOSTR(blend, CONSTANT_COLOR);
+ GLTOSTR(blend, ONE_MINUS_CONSTANT_COLOR);
+ GLTOSTR(blend, CONSTANT_ALPHA);
+ GLTOSTR(blend, ONE_MINUS_CONSTANT_ALPHA);
+ GLTOSTR(blend, SRC_ALPHA_SATURATE);
+ };
+ }
+
void Activate()
{
GLCALL( glBlendFunc(m_src,m_dest) );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-12-28 22:26:35
|
Revision: 645
http://hgengine.svn.sourceforge.net/hgengine/?rev=645&view=rev
Author: axlecrusher
Date: 2009-12-28 22:26:28 +0000 (Mon, 28 Dec 2009)
Log Message:
-----------
use state changers to affect particles for better looking fire
Modified Paths:
--------------
Mercury2/Themes/default/File/scenegraph.xml
Mercury2/Themes/default/Graphic/FireParticles.frag
Mercury2/Themes/default/Graphic/FireParticles.vert
Mercury2/modules/ParticleEmitter.cpp
Mercury2/src/StateChanger.cpp
Modified: Mercury2/Themes/default/File/scenegraph.xml
===================================================================
--- Mercury2/Themes/default/File/scenegraph.xml 2009-12-24 21:28:19 UTC (rev 644)
+++ Mercury2/Themes/default/File/scenegraph.xml 2009-12-28 22:26:28 UTC (rev 645)
@@ -3,6 +3,8 @@
<asset type="StateChanger" file="ColorChange:1,1,1,1" />
<asset type="StateChanger" file="DepthTest:1" />
<asset type="StateChanger" file="LightingSwitch:0" />
+ <asset type="StateChanger" file="DepthWrite:1" />
+ <asset type="StateChanger" file="BlendFunc:SRC_ALPHA,ONE_MINUS_SRC_ALPHA" />
<node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100" name="vp">
<node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0" name="camera">
<node type="transformnode" movz="-5" movy=".2">
@@ -36,6 +38,8 @@
state changer needs some work for proper on and off.
until then had code it for all particles -->
<node type="transformnode" scalex="0.1" scaley="0.1" scalez="0.1">
+ <asset type="StateChanger" file="DepthWrite:0" />
+ <asset type="StateChanger" file="BlendFunc:ONE,ONE" />
<asset type="shader" file="GRAPHIC:FireParticles"/>
<asset type="texture" file="GRAPHIC:flame2.png"/>
<node type="particleemitter"/>
Modified: Mercury2/Themes/default/Graphic/FireParticles.frag
===================================================================
--- Mercury2/Themes/default/Graphic/FireParticles.frag 2009-12-24 21:28:19 UTC (rev 644)
+++ Mercury2/Themes/default/Graphic/FireParticles.frag 2009-12-28 22:26:28 UTC (rev 645)
@@ -1,22 +1,34 @@
uniform sampler2D HG_Texture0;
varying vec4 particleData;
+vec3 Blend(vec3 c1, vec3 c2, float p)
+{
+ return c1*(1.0-p) + c2*p;
+}
+
void main()
{
float pComplete = (particleData.x/particleData.y);
- vec4 blue = vec4(0,0,1,0.125);
- vec4 orange = vec4(1,0.917647059,0.11372549,1);
- vec4 color = vec4(0,0,0,0);
+ vec3 blue = vec3(0,0,1);
+ vec3 orange = vec3(1,0.917647059,0.1372549);
+ vec3 color = vec3(0,0,0);
//blues
- color += blue*(1.0-(pComplete*5.0))*float(pComplete<0.2); //blue
- color += 1.25*orange*(pComplete*5.0)*float(pComplete<0.2); //orange
+ color += Blend(blue, orange, min(1.0,pComplete*3.33))*float(pComplete<0.5);
+ color += Blend(orange, vec3(-3), (pComplete-0.5)*2.0)*float(pComplete>0.5);
+// color += blue*(1.0-(pComplete*3.33))*float(pComplete<0.3); //blue
+// color += orange*(pComplete*3.33)*float(pComplete<0.3); //orange
+
//orange to black fade
- color += 1.25*orange*(1.0-(pComplete-0.2))*float(pComplete>0.2); //orange
- color += vec4(-1,-1,-1,1)*(pComplete)*float(pComplete>0.2); //smoke -1 offset
+// color += 1.25*orange*(1.0-(pComplete-0.2))*float(pComplete>0.2); //orange
+// color += vec4(-1,-1,-1,1)*(pComplete)*float(pComplete>0.2); //smoke -1 offset
- gl_FragData[0] = texture2D(HG_Texture0, gl_TexCoord[0].st)*color;
+ color.rgb *= texture2D(HG_Texture0, gl_TexCoord[0].st).a;
+ color.rgb *= 1.0-(particleData.x/particleData.y);
+
+ gl_FragData[0].rgb = texture2D(HG_Texture0, gl_TexCoord[0].st).rgb*color.rgb;
+ gl_FragData[0].a = texture2D(HG_Texture0, gl_TexCoord[0].st).a;
gl_FragData[0].a *= 1.0-(particleData.x/particleData.y);
}
Modified: Mercury2/Themes/default/Graphic/FireParticles.vert
===================================================================
--- Mercury2/Themes/default/Graphic/FireParticles.vert 2009-12-24 21:28:19 UTC (rev 644)
+++ Mercury2/Themes/default/Graphic/FireParticles.vert 2009-12-28 22:26:28 UTC (rev 645)
@@ -53,7 +53,7 @@
particleData = gl_Color;
vec4 pos = vec4(1.0);
- pos.y = 0.3*(particleData.x*particleData.x);
+ pos.y = 0.3*(particleData.x*particleData.x) + 1.5*(particleData.x/particleData.y);
pos.x = 0.40*((particleData.z-50000.0)/50000.0)*particleData.x; //rand num
pos.z = 0.40*((particleData.w-50000.0)/50000.0)*particleData.x; //rand num
@@ -61,9 +61,9 @@
m[3].xyz = pos.xyz;
mat4 s = mat4(0.0);
- s[0][0] = 1.0+3.0*(particleData.x/particleData.y);
- s[1][1] = 1.0+3.0*(particleData.x/particleData.y);
- s[2][2] = 1.0+3.0*(particleData.x/particleData.y);
+ s[0][0] = 0.5+3.0*(particleData.x/particleData.y);
+ s[1][1] = 0.5+3.0*(particleData.x/particleData.y);
+ s[2][2] = 0.5+3.0*(particleData.x/particleData.y);
s[3][3] = 1.0;
gl_Position = gl_ProjectionMatrix *HG_ViewMatrix *HG_ModelMatrix *m*s* gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
Modified: Mercury2/modules/ParticleEmitter.cpp
===================================================================
--- Mercury2/modules/ParticleEmitter.cpp 2009-12-24 21:28:19 UTC (rev 644)
+++ Mercury2/modules/ParticleEmitter.cpp 2009-12-28 22:26:28 UTC (rev 645)
@@ -257,8 +257,7 @@
void ParticleEmitter::Render(const MercuryMatrix& matrix)
{
- GLCALL( glPushAttrib(GL_ENABLE_BIT|GL_DEPTH_BUFFER_BIT|GL_CURRENT_BIT) );
- GLCALL( glDepthMask( false ) );
+ GLCALL( glPushAttrib(GL_ENABLE_BIT|GL_CURRENT_BIT) );
GLCALL( glDisable(GL_CULL_FACE) );
if (m_bufferID==0)
Modified: Mercury2/src/StateChanger.cpp
===================================================================
--- Mercury2/src/StateChanger.cpp 2009-12-24 21:28:19 UTC (rev 644)
+++ Mercury2/src/StateChanger.cpp 2009-12-28 22:26:28 UTC (rev 645)
@@ -35,7 +35,7 @@
void Activate()
{
- glColor4f( r,g,b,a );
+ GLCALL( glColor4f( r,g,b,a ) );
}
STATECHANGE_RTTI( ColorChange );
@@ -67,9 +67,13 @@
void Activate()
{
if( bEnable )
- glEnable( GL_LIGHTING );
+ {
+ GLCALL( glEnable( GL_LIGHTING ) );
+ }
else
- glDisable( GL_LIGHTING );
+ {
+ GLCALL( glDisable( GL_LIGHTING ) );
+ }
}
STATECHANGE_RTTI( LightingSwitch );
@@ -101,9 +105,13 @@
void Activate()
{
if( bEnable )
- glEnable( GL_DEPTH_TEST );
+ {
+ GLCALL( glEnable( GL_DEPTH_TEST ) );
+ }
else
- glDisable( GL_DEPTH_TEST );
+ {
+ GLCALL( glDisable( GL_DEPTH_TEST ) );
+ }
}
STATECHANGE_RTTI( DepthTest );
@@ -133,7 +141,7 @@
void Activate()
{
- glDepthMask( bEnable );
+ GLCALL( glDepthMask( bEnable ) );
}
STATECHANGE_RTTI( DepthWrite );
@@ -142,6 +150,58 @@
REGISTER_STATECHANGE( DepthWrite );
+class BlendFunc : public StateChange
+{
+public:
+ BlendFunc( const MVector< MString > & sParameters ) : StateChange( sParameters )
+ {
+ if( sParameters.size() < 2 )
+ {
+ LOG.Write( ssprintf( "Error: BlendFunc state has invalid number of parameters(%d).", sParameters.size() ) );
+ return;
+ }
+
+ m_src = StrToBlend(sParameters[0] );
+ m_dest = StrToBlend(sParameters[1] );
+ }
+
+ void Stringify( MString & sOut )
+ {
+ //XXX
+// sOut = ssprintf( "%f", bEnable );
+ }
+
+#define STRTOGL(x,s) if (x==#s) return GL_##s;
+ int StrToBlend(const MString& s)
+ {
+ STRTOGL(s, ZERO);
+ STRTOGL(s, ONE);
+ STRTOGL(s, SRC_COLOR);
+ STRTOGL(s, ONE_MINUS_SRC_COLOR);
+ STRTOGL(s, DST_COLOR);
+ STRTOGL(s, ONE_MINUS_DST_COLOR);
+ STRTOGL(s, SRC_ALPHA);
+ STRTOGL(s, ONE_MINUS_SRC_ALPHA);
+ STRTOGL(s, DST_ALPHA);
+ STRTOGL(s, ONE_MINUS_DST_ALPHA);
+ STRTOGL(s, CONSTANT_COLOR);
+ STRTOGL(s, ONE_MINUS_CONSTANT_COLOR);
+ STRTOGL(s, CONSTANT_ALPHA);
+ STRTOGL(s, ONE_MINUS_CONSTANT_ALPHA);
+ STRTOGL(s, SRC_ALPHA_SATURATE);
+ }
+
+ void Activate()
+ {
+ GLCALL( glBlendFunc(m_src,m_dest) );
+ }
+
+ STATECHANGE_RTTI( BlendFunc );
+ int m_src, m_dest;
+};
+
+REGISTER_STATECHANGE( BlendFunc );
+
//////////////////////////////////////STATE CHANGE CHUNK//////////////////////////////////////
StateChangeRegister & StateChangeRegister::Instance()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-12-24 21:28:26
|
Revision: 644
http://hgengine.svn.sourceforge.net/hgengine/?rev=644&view=rev
Author: axlecrusher
Date: 2009-12-24 21:28:19 +0000 (Thu, 24 Dec 2009)
Log Message:
-----------
better looking fire
Modified Paths:
--------------
Mercury2/Themes/default/File/scenegraph.xml
Mercury2/Themes/default/Graphic/FireParticles.frag
Mercury2/Themes/default/Graphic/FireParticles.vert
Added Paths:
-----------
Mercury2/Themes/default/Graphic/flame2.png
Modified: Mercury2/Themes/default/File/scenegraph.xml
===================================================================
--- Mercury2/Themes/default/File/scenegraph.xml 2009-12-24 20:44:59 UTC (rev 643)
+++ Mercury2/Themes/default/File/scenegraph.xml 2009-12-24 21:28:19 UTC (rev 644)
@@ -37,7 +37,7 @@
until then had code it for all particles -->
<node type="transformnode" scalex="0.1" scaley="0.1" scalez="0.1">
<asset type="shader" file="GRAPHIC:FireParticles"/>
- <asset type="texture" file="GRAPHIC:flame.png"/>
+ <asset type="texture" file="GRAPHIC:flame2.png"/>
<node type="particleemitter"/>
</node>
</node>
Modified: Mercury2/Themes/default/Graphic/FireParticles.frag
===================================================================
--- Mercury2/Themes/default/Graphic/FireParticles.frag 2009-12-24 20:44:59 UTC (rev 643)
+++ Mercury2/Themes/default/Graphic/FireParticles.frag 2009-12-24 21:28:19 UTC (rev 644)
@@ -19,4 +19,4 @@
gl_FragData[0] = texture2D(HG_Texture0, gl_TexCoord[0].st)*color;
gl_FragData[0].a *= 1.0-(particleData.x/particleData.y);
-}
\ No newline at end of file
+}
Modified: Mercury2/Themes/default/Graphic/FireParticles.vert
===================================================================
--- Mercury2/Themes/default/Graphic/FireParticles.vert 2009-12-24 20:44:59 UTC (rev 643)
+++ Mercury2/Themes/default/Graphic/FireParticles.vert 2009-12-24 21:28:19 UTC (rev 644)
@@ -43,7 +43,9 @@
vec3 up = cross(objLookAt, objToEye);
float angleCos = dot(objLookAt, objToEye);
- return glRotate(-acos(angleCos), up);
+ //add in an extra rotation around y to make particles look more unique
+ float o = 360.0*((particleData.z-50000.0)/50000.0);
+ return glRotate(-acos(angleCos), up)*glRotate(o, vec3(0,0,1));
}
void main()
@@ -51,7 +53,7 @@
particleData = gl_Color;
vec4 pos = vec4(1.0);
- pos.y = 0.6*(particleData.x*particleData.x);
+ pos.y = 0.3*(particleData.x*particleData.x);
pos.x = 0.40*((particleData.z-50000.0)/50000.0)*particleData.x; //rand num
pos.z = 0.40*((particleData.w-50000.0)/50000.0)*particleData.x; //rand num
Added: Mercury2/Themes/default/Graphic/flame2.png
===================================================================
(Binary files differ)
Property changes on: Mercury2/Themes/default/Graphic/flame2.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|