Newton 4.00

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Newton 4.00

Postby Julio Jerez » Mon Aug 24, 2020 1:44 am

I started adding the Skelton of the engine.
I created two directories.
Newton-3.14 for the current version.
Newton-4.00 for the new version.

Newton 4 will not have all the legacy that previous versions accumulated over the years.
This version will be based on c++ 11
Which means the minimum version of VS is vs15.

I added the skeleton of what the high lever desing of newton is.
For the people who are interested in following the development and learn how it works, this is a good time to join in.

On of the nice thing of using cop is that we do not need callbacks anymore, since virtual function do the hub very nicely. So the engine is a lot simpler.l
Julio Jerez
Moderator
Moderator
 
Posts: 12425
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton 4.00

Postby Slick » Mon Aug 24, 2020 5:56 am

Great looking forward to following along.
Slick
 
Posts: 330
Joined: Sat Feb 07, 2004 7:24 pm
Location: LA last and France now

Re: Newton 4.00

Postby Julio Jerez » Mon Aug 24, 2020 12:53 pm

nice!!,
I now have all the threading stuff going and I am ready to start population the system stating with bodies.
Julio Jerez
Moderator
Moderator
 
Posts: 12425
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton 4.00

Postby JernejL » Tue Aug 25, 2020 1:02 am

Can we also make some corrections to naming notation in newton 4?
For example name of things, renaming "collisions" to "shapes" would make more sense to people.

Also, if possible maybe instead of newton prefix, use something like "ND"

So.. for example NDCreateSphere() NDCreateDynamicBody() ..

Like i said in other thread, a flat-c interface on top of object classes like we have now would be of big use for some of us who use this, otherwise newton 4 won't be able to interface with some programming languages anymore.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Newton 4.00

Postby Julio Jerez » Tue Aug 25, 2020 10:06 am

All good points.
Yes collision is name to dShape
Since is CPP the is not need for long descriptive names, for example there is not NewtonCreate anymore.
Instead it will be just dNewton world = new dNewton.
Or dBody body = new dDynamicBody.

On the c interface this is top priority.
We will use an automatic translator from c++ to c
I just found that Swig does not do it, but it's not big deal, I will make one using the Newton parcel generator.
I once did it when I translate to objective c, and the abandoned but is not that hard to do that.

If yo sync you will see how the style is now. There is a test project called test that shows how the engine is intended to be used.
Julio Jerez
Moderator
Moderator
 
Posts: 12425
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton 4.00

Postby Julio Jerez » Tue Aug 25, 2020 10:14 am

Also after we made the translator to c, we can eliminate the intermediate step and make translator that goes from CPP to Pascal, Java, csharp, etc.
This will make it that there will not be so many wrappers latest.
We're now 3.14 has one layer since the core is CPP and the interface is c
Plus the the classes has to carry the virtual functions as poter to objects data members.

Finally this automatic translators will convert every class not just the new to core.
Julio Jerez
Moderator
Moderator
 
Posts: 12425
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton 4.00

Postby Julio Jerez » Fri Aug 28, 2020 10:29 am

ok I renamed the engine class prefix for d to nt
I forget that you said ND, which made far more sence, I will probably change to nd later
here is how a simple initialization look like
Code: Select all
int main (int argc, const char * argv[])
{
   ntWorld world;
   world.SetSubSteps(2);
   //newton.SetThreadCount(3);
      
   dVector size(0.5f, 0.25f, 0.8f, 0.0f);
   dVector origin(0.5f, 0.25f, 0.8f, 0.0f);
   BuildPyramid(world, 10.0f, origin, size, 20);

   for (int i = 0; i < 10000; i ++)
   {
      world.Update(1.0f / 60.0f);
      //newton.Sync();
   }

   return 0;
}


here is how a bony get initialized.

Code: Select all
      for (dInt32 i = 0; i < count1; i++)
      {
         ntDynamicBody* const body = new ntDynamicBody();

         body->SetNotifyCallback(new DemobodyNotify);
         
         body->SetMatrix(matrix);
         body->SetCollisionShape(box);
         body->SetMassMatrix(mass, box);

         world.AddBody(body);
         matrix.m_posit.m_z += stepz;
      }


bodies now can have an application object callback like this

Code: Select all
class DemobodyNotify: public ntBodyNotify
{
   public:
   virtual void OnApplyExternalForce(dInt32 threadIndex, dFloat32 timestep)
   {
      ntDynamicBody* const body = m_body->GetAsDynamicBody();
      dAssert(body);

      dVector massMatrix (body->GetMassMatrix());
      dVector force(dVector(0.0f, -10.0f, 0.0f, 0.0f).Scale (massMatrix.m_w));
      body->SetForce(force);
      body->SetTorque(dVector::m_zero);
   }

   virtual void OnTranform(dInt32 threadIndex, const dMatrix& matrix)
   {
      dAssert(0);
   }
};


this of course is optional since an application can subclass a body, a collision, or almost anythong and overload any funtion the want. for example it will be eassy to add use shapes or new bodies.
anyway I am adding the brad phase now, and later will start the solve part.
Julio Jerez
Moderator
Moderator
 
Posts: 12425
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton 4.00

Postby Lax » Sat Sep 05, 2020 8:41 am

Hi Julio,

does that mean, that newton 3.x will be no longer developed?
I have still one request in this topic, which I need in order get my player controller working correctly:

http://newtondynamics.com/forum/viewtopic.php?f=9&t=9592&start=15

Best Regards
Lax
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 182
Joined: Sat Jan 08, 2011 8:24 am

Re: Newton 4.00

Postby Julio Jerez » Sat Sep 05, 2020 1:45 pm

newton 3.14 will be developed until 4.00 can replace it 100%
from that point on, only bug fixes for the people who still prefer continue using it.
but new features will not be retroactive.

at that point I will try to make a translator that will convert the c++ interface of newton 4.xx to match 3.14 as much as possible, but there will always be differences since newton 3.xx and lower has been carrying legacy for about 16 years.
the new one is far more slim and c++ 11 allows for more cross platform.

I see if I can fix that request, this weekend.
Julio Jerez
Moderator
Moderator
 
Posts: 12425
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton 4.00

Postby Julio Jerez » Sat Sep 05, 2020 3:32 pm

here is an example of teh difference between before c++11 and now

this is hwo dreadful the old timer function was, and tshi has diffrent implementation for different platforms all with different granularity and scaling
Code: Select all
dUnsigned64 dGetTimeInMicrosenconds()
{
   static LARGE_INTEGER frequency;
   static LARGE_INTEGER baseCount;
   if (!frequency.QuadPart) {
      QueryPerformanceFrequency(&frequency);
      QueryPerformanceCounter(&baseCount);
   }

   LARGE_INTEGER count;
   QueryPerformanceCounter(&count);
   count.QuadPart -= baseCount.QuadPart;
   dUnsigned64 timeStamp = dUnsigned64(count.QuadPart * LONGLONG(1000000) / frequency.QuadPart);
   return timeStamp;
}


here is the new function
Code: Select all
dUnsigned64 dGetTimeInMicrosenconds()
{
   static std::chrono::high_resolution_clock::time_point timeStampBase = std::chrono::high_resolution_clock::now();
   std::chrono::high_resolution_clock::time_point currentTimeStamp = std::chrono::high_resolution_clock::now();
   dUnsigned64 timeStamp = std::chrono::duration_cast<std::chrono::microseconds>(currentTimeStamp - timeStampBase).count();
   return timeStamp;
}


and this apply to stuff like threads, atomics, and even the stl containers, although I am not using STL containers as I beleive mine are far better by order of magnitude in performance and eassy to use.
I actually test this many time before, and to get an stl container to be come with the newton ones, you need to add special memory allocators. but even with that the eassy to use factor is important.

same apply to stuff like Mutex and atomics.
window Critical section are about 10 to 20 time faster that the general std::mutex
so are atomics.
windows atomics reduce to one cpu instruction, while SLT atomics are hundred of instructions, no sure why is this, but in these cases the eassy to use and cross platform funtionality is a winner,
since usage of those synchronization objects is small, mostly in the most outer loops, over the engine.
Julio Jerez
Moderator
Moderator
 
Posts: 12425
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton 4.00

Postby Lax » Sat Sep 05, 2020 4:38 pm

Yeah C++>=11 rules! Since the 11 standard, C++ has become more powerful and easier to use. The std::chrono functionality is one piece of that.

I'm happy to switch bit by bit to newton 4.00 when the time is ready :D
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 182
Joined: Sat Jan 08, 2011 8:24 am

Re: Newton 4.00

Postby staseg » Mon Sep 07, 2020 3:07 am

It looks quite interesting. How it works.
staseg
 
Posts: 4
Joined: Sun Jun 17, 2018 2:01 pm

Re: Newton 4.00

Postby Julio Jerez » Thu Sep 10, 2020 10:33 am

one of the new nice features of newton 4.0 is that it will be well documented.
I set up the Doxygen project and I am documenting the classes one or two a day starting from the lower to teh higher level.
but even when not adding comment to the classes we still get a nice kind of UML class description, here is how the broad phase looks like.
aligmentNotWorking.png
aligmentNotWorking.png (51.13 KiB) Viewed 14095 times
Julio Jerez
Moderator
Moderator
 
Posts: 12425
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton 4.00

Postby Lax » Fri Sep 11, 2020 3:40 pm

Sounds great! I would also be great to documentate or show some examples of some dos and don'ts. Like you teached me :) Like using velocity or setting position directly within simulation. Or especially when to use kinematic bodies and when to use forces...
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 182
Joined: Sat Jan 08, 2011 8:24 am

Re: Newton 4.00

Postby Julio Jerez » Sat Sep 12, 2020 7:10 pm

yes I will try to do that. this doxygen tool is very good for doing that kind of thing.
I see is possible to add tutorial and code snipped for hwo to do things.

this version of newton will have some different with the old, some feature will be part of cores.
for example
Kinematic bodies are now the core objects instead for the dynamics body. thsi allow for stuff like
setting the velocity of kinematic body will cause to move for ever. as opposed to the old newton that teh app had to integrated the body manually. this allow for this version for newton to work as collision only system.
another funtionality is that teh work no lone own teh bode and the collsion, instead they have to be added or removed by teh app, this will allow for multiplayer when people have many work and bodies can be move from one world to another.
another thing is that triggers can now be a native objects as appose to a before that the were a listener.
al joint will be part of the engine. and adding new one will be a lot easier since ther are just a sub class.
plus make kinematic rag doll will be a lot simple with have to have two different solver.

this will allow for special objects like play controllers, vehicles smart rag dolls to be native engine objects, instead of special listeners objects.

the first one I will try is the player controller.
Julio Jerez
Moderator
Moderator
 
Posts: 12425
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron