The Newton engine is now Open source with a zlib license.

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: The Newton engine is now Open source with a zlib license

Postby Julio Jerez » Tue Mar 22, 2011 8:33 am

I will work on the collision after I complete the destruction
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: The Newton engine is now Open source with a zlib license

Postby PJani » Tue Mar 22, 2011 11:55 am

How much till complete destruction?...joke...at what stage is destruction?
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: The Newton engine is now Open source with a zlib license

Postby Julio Jerez » Wed Mar 23, 2011 6:53 pm

I basically have a working version, but it is not up to the quality I want.

The problem is that my implementation of my geometry Boolean operator is still weak.
It can do Boolean of two meshes but the result is a mesh the cannot be use reliably for further more Boolean. Being like that it is one time operator.

that is not very good for what I have in mind. basically I want and tool that can be use as a building block for make large worlds, like building natural formation, walls etc..

for example say you have a large building with column, walls, fence and other stuff.
you can make a structure turn it is a destructible structure, but the operation is complex to manage, from any point of view.

what I want is that the tool allows a user to select say a column and make destructible, then than column can be used, and re user as building block.
the piece that make the column can be hierarchical, the column may break firth on large pieces, the each piece is in turn a destructible part as well,
and you can handle say one two or three levels of destruction without stressing the performance too much.
Say for example a wall can have three level of destruction: level one Plaster, second level masonry, and third level steel studs.
right now the Boolean only allows for one level, but I am working on that.

By using this strategy I hope people can it will work well with Brush based editors like quake and unreal
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: The Newton engine is now Open source with a zlib license

Postby jay3d » Tue Mar 29, 2011 12:07 pm

Hi guys! :)

Long time I didn't post here, but from now on I will try to contribute to this wonderful Newton project

And lets start with a compile of NGD with MingW64(GCC 4.5.2) in 32-bit mode, I tested it and it fairly stable, but I need someone nice to test it too ;)

link: http://www.mediafire.com/?x7fb0je0hyhbg55

The amazing thing is that the MingW compiled version gets to the speed to the SSE enabled version of MSVC compiled one without even turning on SSE in the example :D , which is a big advantage of speed compiling with GCC 4.5.2

Cheers!
Jay
jay3d
 
Posts: 33
Joined: Sun Jul 13, 2008 11:51 am

Re: The Newton engine is now Open source with a zlib license

Postby Julio Jerez » Tue Mar 29, 2011 1:30 pm

jay3d wrote:Hi guys! :)The amazing thing is that the MingW compiled version gets to the speed to the SSE enabled version of MSVC compiled one without even turning on SSE in the example :D , which is a big advantage of speed compiling with GCC 4.5.2Cheers!Jay


yeah that is what I experienced when I build the engine with GCC 4.x.x
I teh GCC version i use is teh one the comes envede in Linux, witch I beleiv is 4.4.x now
for some reason I get better preformacence with it than visual studion, but then another user (do no remeber teh name now) reported just the oposite with GCC.
I am puzzled with mixed results.
It is almost like GCC uses SSE regearless of what options are passed to the compiler.
That could be the case because I had only tested Linux in 64 bit because, my 32 bit unbuto linux is an AMD laptop tha does not even has SSE.

I am ocupied now with teh new feature, which it is taking way longer than I anticipated, but afte that I will check out you migwing g project to see if It can be added to the download.
I will also add the pascal projects too.

if everthing goes as I have planned I will upload sdk 2.33 by this weekend.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: The Newton engine is now Open source with a zlib license

Postby JernejL » Tue Mar 29, 2011 4:14 pm

jay3d wrote:Hi guys! :)

Long time I didn't post here, but from now on I will try to contribute to this wonderful Newton project

And lets start with a compile of NGD with MingW64(GCC 4.5.2) in 32-bit mode, I tested it and it fairly stable, but I need someone nice to test it too ;)

link: http://www.mediafire.com/?x7fb0je0hyhbg55

The amazing thing is that the MingW compiled version gets to the speed to the SSE enabled version of MSVC compiled one without even turning on SSE in the example :D , which is a big advantage of speed compiling with GCC 4.5.2

Cheers!
Jay


Your dll fails to build this convex hull, NewtonCreateConvexHull will return NULL for this data set where 2.25 msvc build works fine:

0.22499999404, 0.47187501192, 0.1400000006
-0.22499999404, 0.47187501192, 0.1400000006
0.14687499404, 0.55000001192, 0.1400000006
-0.14687499404, 0.55000001192, 0.1400000006
0.22499999404, -0.12187501788, 0.1400000006
-0.22499999404, -0.12187501788, 0.1400000006
0.14687499404, -0.20000001788, 0.1400000006
-0.14687499404, -0.20000001788, 0.1400000006
0.22499999404, 0.47187501192, -0.1400000006
-0.22499999404, 0.47187501192, -0.1400000006
0.14687499404, 0.55000001192, -0.1400000006
-0.14687499404, 0.55000001192, -0.1400000006
0.22499999404, -0.12187501788, -0.1400000006
-0.22499999404, -0.12187501788, -0.1400000006
0.14687499404, -0.20000001788, -0.1400000006
-0.14687499404, -0.20000001788, -0.1400000006


Additionally, all trimeshes generated end up blank.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: The Newton engine is now Open source with a zlib license

Postby Julio Jerez » Tue Mar 29, 2011 5:51 pm

Delfi I believe that this is not Jay3d falt, it is all mine
I believe he is working of SVN and I have few things commented out because the modification sI am making the the MeshEffect tool

The convex hull code is commend out, because I am changing it to work in double, this is what is does now so it will fail
Code: Select all
bool dgCollisionConvexHull::Create (dgInt32 count, dgInt32 strideInBytes, const dgFloat32* const vertexArray, dgFloat32 tolerance)
{
   _ASSERTE (0);
/*


I do that some time when I make a modification to a base class, I know I should not check it in but, now I am using SVN as my archive system.
anyway I think I have the code in better shape now and soon I will check in a stable version.

Jay3d if I am correct in tha you are using the corrent SVN, all you nee to do is update an dteh hull stuff is fixed.
sorry about that inconvenient.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: The Newton engine is now Open source with a zlib license

Postby JernejL » Tue Mar 29, 2011 7:00 pm

oh :( well a similar problem is with trimeshes too - they are empty. Also there is a new crash when building specific trimesh in 2.32 (see details in that other thread about continous collision problem)
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: The Newton engine is now Open source with a zlib license

Postby LaKraven_Studios » Tue Mar 29, 2011 7:08 pm

I'm checking out from the SVN now... should I wait before attempting a build, or is it "build-stable" now?

Hi, by the way... I've actually been using Newton for a very long time... just decided to register in the forums :) Really pleased to see Newton go Open Source! It gives us all an opportunity to help expand on it, or "improve" it (if that's even possible).
LaKraven_Studios
 
Posts: 1
Joined: Tue Mar 29, 2011 7:05 pm

Re: The Newton engine is now Open source with a zlib license

Postby jay3d » Wed Mar 30, 2011 4:36 am

Julio Jerez wrote:Jay3d if I am correct in tha you are using the corrent SVN, all you nee to do is update an dteh hull stuff is fixed.
sorry about that inconvenient.


Yes I'm checking from SVN, Thanks for the correction

I have put up a patch to fix some issues when compiling with MingW32/64

Code: Select all
Index: packages/dContainers/dThread.cpp
===================================================================
--- packages/dContainers/dThread.cpp   (revision 456)
+++ packages/dContainers/dThread.cpp   (working copy)
@@ -17,8 +17,8 @@
    #include <Windows.h>
    #include <crtdbg.h>
 #endif
-
-#ifdef _LINUX_VER
+
+#ifdef _POSIX_VER
    #include <pthread.h>
    #include <semaphore.h>
    #include <unistd.h>
@@ -28,7 +28,7 @@
 
 static inline void dInterlockedIncrement (int* const Addend )
 {
-   #if (defined (_LINUX_VER))
+   #if (defined (_POSIX_VER))
       __sync_fetch_and_add ((int32_t*)Addend, 1 );
    #endif
 
@@ -44,7 +44,7 @@
 
 static inline void dInterlockedDecrement(int* const Addend)
 {
-   #if (defined (_LINUX_VER))
+   #if (defined (_POSIX_VER))
       __sync_fetch_and_sub ((int32_t*)Addend, 1 );
    #endif
 
@@ -60,7 +60,7 @@
 
 static inline int dInterlockedExchange (int* spin, int testValue)
 {
-   #if (defined (_LINUX_VER))
+   #if (defined (_POSIX_VER))
       return __sync_val_compare_and_swap((int32_t*)spin, !testValue, testValue);
    #endif
 
@@ -89,7 +89,7 @@
    m_threadhandle = _beginthreadex( NULL, 0, TaskCallback, this, 0, NULL);
 #endif
 
-#if (defined (_LINUX_VER) || defined (_MAC_VER))
+#if (defined (_POSIX_VER) || defined (_MAC_VER))
    pthread_create( &m_threadhandle, NULL, TaskCallback, this);
 #endif
 }
@@ -105,7 +105,7 @@
 #if defined (_MSC_VER)
 unsigned _stdcall dThread::TaskCallback(void *param)
 #endif
-#if (defined (_LINUX_VER) || defined (_MAC_VER))
+#if (defined (_POSIX_VER) || defined (_MAC_VER))
 void* dThread::TaskCallback(void *param)
 #endif
 {
@@ -169,7 +169,7 @@
       Sleep(0);
    #endif
 
-   #if (defined (_LINUX_VER) || defined (_MAC_VER))
+   #if (defined (_POSIX_VER) || defined (_MAC_VER))
       sched_yield();
    #endif
 }
Index: packages/dContainers/dThread.h
===================================================================
--- packages/dContainers/dThread.h   (revision 456)
+++ packages/dContainers/dThread.h   (working copy)
@@ -13,7 +13,16 @@
 #ifndef __DTHREAD_H__
 #define __DTHREAD_H__
 
+#if ( defined (_LINUX_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER) )
+    #define _POSIX_VER
+    #include <pthread.h>
+#endif
 
+#if ( defined (_MINGW_32_VER) || defined (_MINGW_64_VER) )
+    #include <stdint.h>
+    #include <crtdbg.h>
+#endif
+
 class dThread
 {
    public:
@@ -37,7 +46,7 @@
    static unsigned _stdcall TaskCallback(void *param);
 #endif
 
-#if (defined (_LINUX_VER) || defined (_MAC_VER))
+#if (defined (_POSIX_VER) || defined (_MAC_VER))
    static void* TaskCallback(void *Param);
 #endif
 
@@ -50,9 +59,9 @@
    uintptr_t m_threadhandle;
 #endif
 
-#if (defined (_LINUX_VER) || defined (_MAC_VER))
+#if (defined (_POSIX_VER) || defined (_MAC_VER))
    pthread_t m_threadhandle;
 #endif
 };
 
-#endif
\ No newline at end of file
+#endif
Index: packages/dMath/dMathDefines.h
===================================================================
--- packages/dMath/dMathDefines.h   (revision 456)
+++ packages/dMath/dMathDefines.h   (working copy)
@@ -16,6 +16,10 @@
 #include <math.h>
 #include <float.h>
 
+#if ( defined (_MINGW_32_VER) || defined (_MINGW_64_VER) )
+    #include <crtdbg.h>
+#endif
+
 #ifndef dFloat
    #ifdef __USE_DOUBLE_PRECISION__
       typedef double dFloat;
@@ -36,14 +40,14 @@
 #define dAcos(x)   dFloat (acos (dFloat(x)))
 #define   dAtan2(x,y) dFloat (atan2 (dFloat(x), dFloat(y)))
 
-#ifndef _MSC_VER
+#if ( !defined (_MSC_VER) && !defined (_MINGW_32_VER) && !defined (_MINGW_64_VER) )
    #define _ASSERTE(x)
-   #ifndef min
-      #define min(a,b) ((a < b) ? (a) : (b))
-      #define max(a,b) ((a > b) ? (a) : (b))
-   #endif
 #endif
 
+#ifndef min
+    #define min(a,b) ((a < b) ? (a) : (b))
+    #define max(a,b) ((a > b) ? (a) : (b))
+#endif
 
 #ifdef _MSC_VER
    #ifdef _DEBUG
Index: packages/thirdParty/tinyxml/tinyxmlparser.cpp
===================================================================
--- packages/thirdParty/tinyxml/tinyxmlparser.cpp   (revision 456)
+++ packages/thirdParty/tinyxml/tinyxmlparser.cpp   (working copy)
@@ -354,7 +354,7 @@
    }
    else
    {
-      while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' )
+      while ( ( *p && IsWhiteSpace( *p ) ) || *p == '\n' || *p =='\r' )
          ++p;
    }
 


Cheers!
Jay
jay3d
 
Posts: 33
Joined: Sun Jul 13, 2008 11:51 am

Re: The Newton engine is now Open source with a zlib license

Postby Julio Jerez » Wed Mar 30, 2011 1:21 pm

@LaKraven_Studios,

if you sync to svn, the current Physics engine should be working, what is in shaking ground is the new stuff I am working on now.
the convex hull thoig was a mistake I made checking in something I should not, then I continues working and I forgot that I chekc those funtion comnetd out.
but I corrected now.

@Jay3D
I will commit that Patch,
for what I see the define POSIT_VER is a standard for project using pthread, thtat is much better than teh way I added.
excelent!!

edit:
oh c_r_a_p I found another commented out function, I have to stop that havit of mine of commenting out function for so long and then forgetting that they are like that.
Before it did not matter because I was the only user of the repository, but nowo that is not longer the case.
anyway I will fix it tonight before uploading SDK 2.33
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: The Newton engine is now Open source with a zlib license

Postby jay3d » Wed Mar 30, 2011 8:01 pm

Hi

Another patch to support 64 bit assembly :)

Code: Select all
Index: dgTypes.cpp
===================================================================
--- dgTypes.cpp   (revision 465)
+++ dgTypes.cpp   (working copy)
@@ -190,33 +190,41 @@
    void cpuid(dgUnsigned32 op, dgUnsigned32 reg[4])
    {
       asm volatile(
+#ifdef _MINGW_64_VER
+            "pushq %%rbx      \n\t" /* save %rbx */
+#else
          "pushl %%ebx      \n\t" /* save %ebx */
+#endif
          "cpuid            \n\t"
          "movl %%ebx, %1   \n\t" /* save what cpuid just put in %ebx */
+#ifdef _MINGW_64_VER
+            "popq %%rbx       \n\t" /* restore the old %rbx */
+#else
          "popl %%ebx       \n\t" /* restore the old %ebx */
+#endif
          : "=a"(reg[0]), "=r"(reg[1]), "=c"(reg[2]), "=d"(reg[3])
          : "a"(op)
          : "cc");



Cheers!
Jay
jay3d
 
Posts: 33
Joined: Sun Jul 13, 2008 11:51 am

Re: The Newton engine is now Open source with a zlib license

Postby Julio Jerez » Wed Mar 30, 2011 8:08 pm

assembly? what for.

I do not want to add assembly to the engine because them it becomes too diffcult to compiler on any new platform.

Oh I see that is the function tah enable the SSE.

I wish GCC had an more elegant way to recognize if there is SSE in teh system,
In windows I do it by using a exeption, and in Mac tehr si a OS system call,

I will add those two patches tonight.

Tell me something how do I apply the patch, should I copy and Paste the code and save as a file, then run SVN Patch util?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: The Newton engine is now Open source with a zlib license

Postby jay3d » Wed Mar 30, 2011 8:39 pm

Julio Jerez wrote:Tell me something how do I apply the patch, should I copy and Paste the code and save as a file, then run SVN Patch util?


yes save the code and use the patch util to apply it locally or remotely
Thanks!

Cheers!
Jay
jay3d
 
Posts: 33
Joined: Sun Jul 13, 2008 11:51 am

Re: The Newton engine is now Open source with a zlib license

Postby jay3d » Thu Mar 31, 2011 5:33 am

Hi

My latest patch to enable using pthreads code when using MingW32/64 compilers

Code: Select all
Index: dgThreads.cpp
===================================================================
--- dgThreads.cpp   (revision 456)
+++ dgThreads.cpp   (working copy)
@@ -26,11 +26,11 @@
 
 static inline void dgThreadYield()
 {
-   #if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+   #if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
       Sleep(0);
    #endif
 
-   #if (defined (_LINUX_VER) || defined (_MAC_VER))
+   #if (defined (_POSIX_VER) || defined (_MAC_VER))
       #ifndef _MAC_IPHONE
          sched_yield();
       #endif
@@ -40,13 +40,13 @@
 
 static inline void dgSpinLock (dgInt32 *spin)
 {
-   #if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+   #if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
       while (InterlockedExchange((long*) spin, 1)) {
          Sleep(0);
       }
    #endif
 
-   #if (defined (_LINUX_VER))
+   #if (defined (_POSIX_VER))
       while(! __sync_bool_compare_and_swap((int32_t*)spin, 0, 1) ) {
          sched_yield();
       }
@@ -70,11 +70,11 @@
 
 static inline void dgInterlockedIncrement (dgInt32* Addend )
 {
-   #if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+   #if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
       InterlockedIncrement((long*) Addend);
    #endif
 
-   #if (defined (_LINUX_VER))
+   #if (defined (_POSIX_VER))
       __sync_fetch_and_add ((int32_t*)Addend, 1 );
    #endif
 
@@ -87,11 +87,11 @@
 
 static inline void dgInterlockedDecrement(dgInt32* Addend)
 {
-   #if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+   #if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
       InterlockedDecrement((long*) Addend);
    #endif
 
-   #if (defined (_LINUX_VER))
+   #if (defined (_POSIX_VER))
       __sync_fetch_and_sub ((int32_t*)Addend, 1 );
    #endif
 
@@ -104,7 +104,7 @@
 
 dgThreads::dgThreads()
 {
-   #if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+   #if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
       SYSTEM_INFO sysInfo;
       GetSystemInfo(&sysInfo);
       m_numberOfCPUCores = dgInt32 (sysInfo.dwNumberOfProcessors);
@@ -113,17 +113,23 @@
       memset (m_threadhandles, 0, sizeof (m_threadhandles));
    #endif   
 
-   #if (defined (_LINUX_VER))
-      m_numberOfCPUCores = sysconf(_SC_NPROCESSORS_ONLN);
+   #if (defined (_POSIX_VER))
+        #if (defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+            SYSTEM_INFO sysInfo;
+            GetSystemInfo(&sysInfo);
+            m_numberOfCPUCores = dgInt32 (sysInfo.dwNumberOfProcessors);
+      #else
+            m_numberOfCPUCores = sysconf(_SC_NPROCESSORS_ONLN);
+      #endif
 
       m_numOfThreads = 0;
       m_exit = false;
@@ -210,7 +216,7 @@
       DestroydgThreads();
    }
 
-   #if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+   #if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
       if ((threads > 1) && (m_numberOfCPUCores > 1)) {
          m_numOfThreads = GetMin (threads, m_numberOfCPUCores);
 
@@ -230,7 +236,7 @@
    #endif
 
 
-   #if (defined (_LINUX_VER) || defined (_MAC_VER))
+   #if (defined (_POSIX_VER) || defined (_MAC_VER))
       if ((threads > 1) && (m_numberOfCPUCores > 1)) {
          #ifdef _MAC_IPHONE
             m_numOfThreads = 0;
@@ -254,13 +260,13 @@
 
 void dgThreads::DestroydgThreads()
 {
-   #if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+   #if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
       _ASSERTE (m_workInProgress == 0);
 
       while(m_workInProgress > 0){
@@ -292,7 +298,7 @@
       m_numOfThreads = 0;
    #endif
 
-   #if (defined (_LINUX_VER) || defined (_MAC_VER))
+   #if (defined (_POSIX_VER) || defined (_MAC_VER))
 
       while(m_workInProgress > 0){
          usleep(100000);
@@ -330,20 +336,20 @@
       job->ThreadExecute();
    } else {
 
-      #if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+      #if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
          dgInterlockedIncrement(&m_workInProgress);
          if(WaitForSingleObject(m_emptySlot,INFINITE) != WAIT_OBJECT_0){
             return(0);
          }
 
-         EnterCriticalSection(&m_criticalSection);
+         EnterCriticalSection(&m_criticalSection);
          m_queue[m_topIndex] = job;
          m_topIndex = (m_topIndex + 1) % DG_MAXQUEUE;
          ReleaseSemaphore(m_workToDo,1,NULL);
          LeaveCriticalSection(&m_criticalSection);
       #endif
 
-      #if (defined (_LINUX_VER) || defined (_MAC_VER))
+      #if (defined (_POSIX_VER) || defined (_MAC_VER))
          dgInterlockedIncrement(&m_workInProgress);
          while ( m_emptySlot == 0 ) {
             dgThreadYield();
@@ -362,10 +368,10 @@
 
 
 
-#if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+#if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
    dgUnsigned32 _stdcall dgThreads::ThreadExecute(void *param)
 #endif
-#if (defined (_LINUX_VER) || defined (_MAC_VER))
+#if (defined (_POSIX_VER) || defined (_MAC_VER))
    void* dgThreads::ThreadExecute(void *param)
 #endif
 {
@@ -377,7 +383,7 @@
 
 dgInt32  dgThreads::GetWork(dgWorkerThread** job)
 {
-   #if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+   #if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
       HANDLE hWaitHandles[2];
       hWaitHandles[0] = m_workToDo;
       hWaitHandles[1] = m_exit;
@@ -386,15 +392,15 @@
          return 0;
       }
 
-      EnterCriticalSection(&m_criticalSection);
+      EnterCriticalSection(&m_criticalSection);
       *job = m_queue[m_bottomIndex];
       m_bottomIndex = (m_bottomIndex + 1) % DG_MAXQUEUE;
       ReleaseSemaphore(m_emptySlot,1,NULL);
       LeaveCriticalSection(&m_criticalSection);
    #endif
 
-   #if (defined (_LINUX_VER) || defined (_MAC_VER))
-      for (;;) {
+   #if (defined (_POSIX_VER) || defined (_MAC_VER))
+      for (;;) {
          while ( m_workToDo == 0 ) {
             dgThreadYield();
          }
Index: dgThreads.h
===================================================================
--- dgThreads.h   (revision 456)
+++ dgThreads.h   (working copy)
@@ -24,7 +24,18 @@
 
 #define DG_MAXQUEUE      16
 
+#if ( defined (_LINUX_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER) )
+    #define _POSIX_VER
+    #include <pthread.h>
+   #include <semaphore.h>
+   #include <unistd.h>
+#endif
 
+#if ( defined (_MINGW_32_VER) || defined (_MINGW_64_VER) )
+    #include <stdint.h>
+    #include <crtdbg.h>
+#endif
+
 class dgWorkerThread
 {
    public:
@@ -65,17 +76,17 @@
    {
       dgInt32 m_ticks;
       dgInt32 m_threadIndex;
-      dgThreads* m_manager;
+      dgThreads* m_manager;
    };
 
    void DoWork(dgInt32 threadIndex);
    dgInt32 GetWork(dgWorkerThread** cWork);
 
-#if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+#if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
    static dgUnsigned32 _stdcall ThreadExecute(void *Param);
 #endif
 
-#if (defined (_LINUX_VER) || defined (_MAC_VER))
+#if (defined (_POSIX_VER) || defined (_MAC_VER))
    static void* ThreadExecute(void *Param);
 #endif
 
@@ -86,7 +97,7 @@
    dgInt32 m_workInProgress;
    mutable dgInt32 m_globalSpinLock;
 
-#if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER))
+#if (defined (_WIN_32_VER) || defined (_WIN_64_VER))
    HANDLE m_exit;
    HANDLE m_workToDo;
    HANDLE m_emptySlot;
@@ -95,7 +106,7 @@
    HANDLE m_threadhandles[DG_MAXIMUN_THREADS];
 #endif
 
-#if (defined (_LINUX_VER) || defined (_MAC_VER))
+#if (defined (_POSIX_VER) || defined (_MAC_VER))
    bool m_exit;
    dgInt32 m_emptySlot;
    dgInt32 m_workToDo;


Cheers!
Jay
jay3d
 
Posts: 33
Joined: Sun Jul 13, 2008 11:51 am

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 11 guests