<div dir="ltr">It might be worth noting that making a call from managed to unmanaged code typically has a lot of overhead. I've found that making fewer calls while passing many data in arrays of native types is often a lot faster than making many calls with fewer data. I suspect you've probably experienced similar but I thought I'd mention it on the odd chance you haven't. Here's an interesting article about it: <a href="http://www.codeproject.com/Articles/253444/PInvoke-Performance">http://www.codeproject.com/Articles/253444/PInvoke-Performance</a><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 14, 2015 at 12:26 PM, <span dir="ltr"><<a href="mailto:gamucf@gmail.com" target="_blank">gamucf@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi! That is very useful information, many thanks! As we go forward, I'd like to reach out to you more if that would be okay. We are making the C#/C++ interface be as simple as possible and trying to keep as much native stuff on the native side as possible. Just a whole lot easier especially with differences in compiler/linker flags between OpenSim and PhysX (Robert can go into a ton more on that).<span class="HOEnZb"><font color="#888888"><br>
<br>
Glenn</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<br>
<br>
On Thu, 13 Aug 2015, Mister Blue wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello Robert and Glenn,<br>
I'm the main person behind BulletSim and feel free to send me email (<br>
<a href="mailto:misterblue@misterblue.com" target="_blank">misterblue@misterblue.com</a>) if you have any questions about integrating a<br>
physics engine with OpenSimulator.<br>
<br>
Some general ramblings about BulletSim:<br>
<br>
The C# part of BulletSim can be in addin-modules -- it doesn't need to be<br>
'in core' but needs to be built with<br>
core so it can be an addin module. Your new physics engine can start out<br>
as an addin module and, like BulletSim, prove itself before graduating into<br>
core.<br>
<br>
There is a separate OpenSimulator source tree... opensim-libs at "git://<br>
<a href="http://opensimulator.org/git/opensim-libs" rel="noreferrer" target="_blank">opensimulator.org/git/opensim-libs</a>" that has a bunch of the non-core parts<br>
of OpenSimulator (http server, old and ancient other tries at he physics<br>
engine, ...). The C++ portion of BulletSim is in<br>
'opensim-libs/trunk/unmanaged/BulletSim' and there are the instructions for<br>
fetching the Bullet sources, patching same, and then building with the<br>
interface to the C# code). The C++ wrapper mostly deals with passing the<br>
structures back and forth between the C# and C++ code (pinned memory for<br>
the position updates and collisions, copying meshes in arrays of floats,<br>
...)<br>
<br>
The BulletSim design is around making a simulation step be only one<br>
transition between C# and C++. So, under normal running conditions, there<br>
is only one transition per simulation step and the data (position updates<br>
and collisions) are passed in pinned memory so there is no copy. 98% of the<br>
C# code deals with doing and adapting Bullet to what OpenSimulator required<br>
(link sets (ugh!), ...). The C# -> C++ interface for BulletSim is rather<br>
large... physics engines seem to have lots of calls for all their features.<br>
Bullet, for instance, has what seems like zillions of methods for changing<br>
constraint parameters. I made those appear in the interface to C#. If I had<br>
it to do over again, I'd probably go more with a functional design where<br>
there is a "call a named function with parameter blob" design so the C#/C++<br>
interface was smaller and new function could be added without changing the<br>
binding of the DLL then use some fancy reflection to build the binding on<br>
both sides<br>
<br>
The .NET C#/C++ binding is pretty good except that int's and boolean's<br>
change size between 32 and 64bits... if you look at the BulletSim interface<br>
you'll see I use floats and arrays of floats everywhere because they are<br>
always 32 bit.<br>
<br>
I recently played with building "BulletThrift"... a version of BulletSim<br>
that used Thrift to call a remote process physics engine (experiment in<br>
distributed physics). It didn't get finished mainly because the existing<br>
interface to the C++ module is so large. BulletSim actually has a HAL layer<br>
to access the physics engine and there are two physics engines: the C++<br>
Bullet and a C# port of Bullet. The latter was last used by Nebadon to run<br>
OpenSimulator on a Raspberry PI. But this also means it is easy to add a<br>
link to a remote Bullet. That's where I was going to add BulletThrift that<br>
would call across the network to a remote Bullet server. My main reason for<br>
doing this was to be able to run Bullet in a pure C++ environment where<br>
debugging wouldn't be complicated by the managed/unmanaged environment.<br>
<br>
If you distributed the physics engine, operationally, I'd expect you'd see<br>
some of the things that happen when<br>
running BulletSim on its own thread like jitter caused when there is a<br>
'beat' between the physics simulation<br>
time and the simulator heartbeat. BulletSim running on its own thread<br>
means that the physics engine is called<br>
on its own thread and the passing back of collisions and position updates<br>
happens when the simulator heartbe<br>
at thread calls into the physics engine.<br>
<br>
Anyway, feel free to ask about my learnings.<br>
<br>
-- mb<br>
<br>
<br>
<br>
<br>
On Tue, Aug 11, 2015 at 8:45 AM, Myron Curtis <<a href="mailto:myronjc@virtualworldsgrid.com" target="_blank">myronjc@virtualworldsgrid.com</a><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
wrote:<br>
</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks,<br>
It would add the extra overhead, but it might also enable a central server<br>
to manage the physics for several grid instances, and it might be more<br>
compatible with web based access to a virtual world if we can ever get that<br>
built.<br>
Myron<br>
<br>
-----Original Message-----<br>
From: <a href="mailto:opensim-dev-bounces@opensimulator.org" target="_blank">opensim-dev-bounces@opensimulator.org</a><br>
[mailto:<a href="mailto:opensim-dev-bounces@opensimulator.org" target="_blank">opensim-dev-bounces@opensimulator.org</a>] On Behalf Of Kevin Cozens<br>
Sent: Monday, August 10, 2015 7:00 PM<br>
To: <a href="mailto:opensim-dev@opensimulator.org" target="_blank">opensim-dev@opensimulator.org</a><br>
Subject: Re: [Opensim-dev] PhysX Development<br>
<br>
On 15-08-10 06:39 PM, Myron Curtis wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Could you use PHP as the wrapper?<br>
</blockquote>
<br>
Interesting idea but I could see it adding (a lot of?) extra overhead<br>
compared to coding the wrapper in the same language as Open Simulator or<br>
PhysX.<br>
<br>
--<br>
Cheers!<br>
<br>
Kevin.<br>
<br>
<a href="http://www.ve3syb.ca/" rel="noreferrer" target="_blank">http://www.ve3syb.ca/</a> |"Nerds make the shiny things that<br>
distract<br>
Owner of Elecraft K2 #2172 | the mouth-breathers, and that's why we're<br>
| powerful!"<br>
#include <disclaimer/favourite> | --Chris Hardwick<br>
_______________________________________________<br>
Opensim-dev mailing list<br>
<a href="mailto:Opensim-dev@opensimulator.org" target="_blank">Opensim-dev@opensimulator.org</a><br>
<a href="http://opensimulator.org/cgi-bin/mailman/listinfo/opensim-dev" rel="noreferrer" target="_blank">http://opensimulator.org/cgi-bin/mailman/listinfo/opensim-dev</a><br>
<br>
_______________________________________________<br>
Opensim-dev mailing list<br>
<a href="mailto:Opensim-dev@opensimulator.org" target="_blank">Opensim-dev@opensimulator.org</a><br>
<a href="http://opensimulator.org/cgi-bin/mailman/listinfo/opensim-dev" rel="noreferrer" target="_blank">http://opensimulator.org/cgi-bin/mailman/listinfo/opensim-dev</a><br>
<br>
</blockquote>
<br>
</blockquote>
_______________________________________________<br>
Opensim-dev mailing list<br>
<a href="mailto:Opensim-dev@opensimulator.org" target="_blank">Opensim-dev@opensimulator.org</a><br>
<a href="http://opensimulator.org/cgi-bin/mailman/listinfo/opensim-dev" rel="noreferrer" target="_blank">http://opensimulator.org/cgi-bin/mailman/listinfo/opensim-dev</a><br>
</div></div></blockquote></div><br></div>