Jump to content

  • Log In with Google      Sign In   
  • Create Account

Scourage

Member Since 29 Jan 2000
Offline Last Active Jul 11 2016 11:03 AM

Posts I've Made

In Topic: Sharing object between 2 threads

29 June 2016 - 08:06 AM

It sounds like your main thread is running the simulation and your auxiliary thread is rendering the entities.  You can probably get away with reading the entity without locking if you make sure that you only read from it.  You need to look at it from a memory contention standpoint.  If you don't lock, you  run the risk of having part of the data change on you while you are reading from it.  It's up to you if that is a bad thing or not.

 

Double buffering the data may help prevent partial updates, but you need to prevent the buffers from being swapped while somebody is reading from it (again locking). 

 

You might want to consider your threading approach.  Having a separate render thread may not be the best thing in this case.  You might want to have the main thread do an update pass then a render pass but use a worker thread pool to achieve parallelism.  Instead of having a single "coarse grain" thread for rendering, use a bunch of work threads to get "fine grain" threading within a single phase.  

 

For example: In your main game loop, you update your game objects by passing them all off to worker threads to be done in parallel.  Then when they're all done, you go to the render phase.  In your render phase, you do entity visibility culling and build render commands per entity in a bunch of worker threads in parallel.  if you are able to encapsulate the render commands, you can build a list of them in the main thread and then pass the entire list off to a coarse grained rendering thread for execution while your main thread goes back to updating.  

 

cheers, 

 

Bob


In Topic: Object reference not set to an instance of an object

20 April 2016 - 01:24 PM

So the problem is that you are expecting the elements of the array to be there, but they're not.  You're only allocating the space for the elements in your array, you then need to put something there.  

PlanetDetails[] Planet = new PlanetDetails[10];
for(int i=0; i<10;i++)
  Planet[i]=new PlanetDetails();

Cheers, 

 

Bob


In Topic: Thoughts on the Boost.Build system? (as opposed to CMake?)

14 April 2016 - 10:48 AM

I use CMake for work, but I've been using premake (https://premake.github.io/) for personal projects and have been slowly introducing it at work.  Premake uses Lua as it's configuration language.  I find it much easier to work with than CMake, especially when writing functions to do something complicated. 

 

To answer your original question: when I was looking for alternatives to CMake, I tried bjam, but didn't find it very user friendly.  I had used scons for a long time when working on Blender, so I knew that wasn't what I was looking for.  I stumbled onto premake and it just worked out really well for me.

 

cheers, 

 

Bob


In Topic: Engine RPM and wheel angular velocity

24 March 2016 - 02:07 PM

 

BoredEngineer, 

 

Thanks for the link, that's a good article. 

 

Cheers, 

 

Bob


In Topic: Engine RPM and wheel angular velocity

24 March 2016 - 01:29 PM

I would make engine RPM be some function of fuel flow or normalized throttle input.  Maybe something linear where 0 throttle = 500rpm (idle) and a throttle of 1.0 = 5000rpm.  You could then convert RPM to torque using some kind of mapping function, maybe use a datafile that defines the graph so you can have different types of engines.  Here's an example image that I found showing RPM -> torque

 

MU-X+torque_curve.png

 

Once you have a torque value from your rpm value, then you need to apply your "transmission." Based on the current gear, maybe it's in reverse, you get a wheel revolution speed out of it and use that value to move your model.  To implement a clutch, you would have a function before your transmission that could simply either pass through the torque value or pass a 0 when the clutch pedal is pressed.

 

I'm sure I'm missing a bunch of things, but does that help answer your question?

 

cheers, 

 

Bob


PARTNERS