CN_VARIABLE scene param not available with Bleeding?

Rasengan

10-07-2008 14:09:43

Hello,

I'm trying to set the "time_step_method" to "variable", but it seems that the param not exist with Nx 1.0_21.

So, I've tested this:

...mWorld->createScene(..., "gravity: yes, floor: yes, time-step-method: variable");

but app crash.

I want use this param to test if it would be possible to avoid some stuttering with camera collision.

betajaen

10-07-2008 14:43:09

The CN_VARIABLE is in '22 and looking in the '21 SVN source it seems to be the same in that.

Personally I would use the accumulator though; It's designed to prevent stuttering.

Rasengan

10-07-2008 15:53:24

sry my mistake:

sceneParams.mController = NxOgre::SceneParams::CN_VARIABLE;

available to r21.

I've used CN_ACCUMULATOR but camera still "stuttering" when collide something, maybe I've to put a kind of "delta time variable" for accumulator somewhere but I'don't know exactly how to deal with that...

There is no more stuttering with camera collision in the application, when CN_VARIABLE is used, cool!

betajaen

10-07-2008 16:00:52

It's automatic; you shouldn't need to mess around with the deltaTime at all.


However, I think there is a slight bug in the interpolation code in '21 that is fixed in '22. If your willing you can patch it yourself. Just ask for the fixes and I'll hunt them down and post them.

Rasengan

10-07-2008 16:04:44

Yes i will! :)

betajaen

10-07-2008 16:11:04

Okay this has been proven to work with all RenderableSources. Assuming your Camera is attached to a RenderableSource (which mode is RM_Interpolate); i.e. a Body with a SceneNode, then it shouldn't jitter or not to much.

NxOgreSceneController.cpp

TimeStep AccumulatorSceneController::Simulate(NxReal) {

double deltaTime = mTimer->micro() * 1.0e-6;
if( deltaTime > 0.2 ) // 5hz
{
mTimer->reset();
deltaTime = 0.2;
}

mAccumulator += deltaTime;
TimeStep ts;
while (mAccumulator >= mMaxStep) {
ts.Alpha_PhysicsSimulated = true;
mNxScene->simulate(mMaxStep);
mNxScene->flushStream();
mNxScene->fetchResults(NX_RIGID_BODY_FINISHED, true);
mAccumulator -= mMaxStep;
}

mAlpha = mAccumulator / mMaxStep;
mTimer->reset();


ts.Delta = mMaxStep;
ts.Alpha = mAlpha;

return ts;
}


NxOgreRenderableSource.cpp

void RenderableSource::render_Interpolate(const TimeStep& ts) {
Pose sourcePose = getSourcePose(ts);
if(ts.Alpha_PhysicsSimulated)
mAlphaPose = sourcePose;
mRenderPose = NxInterpolate(mAlphaPose, sourcePose, ts.Alpha);
mRenderable->setPose(mRenderPose);
}


NxOgreTimeStep.h

class NxPublicClass TimeStep {
public:

TimeStep() : Delta(0), Alpha(0), Alpha_PhysicsSimulated(false) {}

/** \brief Time since last simulation/frame/time step
*/
NxReal Delta;

/** \brief Accumulator alpha value used with interpolation.
*/
NxReal Alpha;

/** \brief If the Accumulator simulated during this timestep.
*/
bool Alpha_PhysicsSimulated;
};