mirror of
https://github.com/bulletphysics/bullet3
synced 2024-12-13 21:30:09 +00:00
example browser: slider widget improvements
This commit is contained in:
parent
936a104fb2
commit
49b27f30bd
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
typedef void (*SliderParamChangedCallback) (float newVal);
|
typedef void (*SliderParamChangedCallback) (float newVal, void* userPointer);
|
||||||
#include "LinearMath/btScalar.h"
|
#include "LinearMath/btScalar.h"
|
||||||
|
|
||||||
struct SliderParams
|
struct SliderParams
|
||||||
@ -16,6 +16,7 @@ struct SliderParams
|
|||||||
btScalar* m_paramValuePointer;
|
btScalar* m_paramValuePointer;
|
||||||
void* m_userPointer;
|
void* m_userPointer;
|
||||||
bool m_clampToNotches;
|
bool m_clampToNotches;
|
||||||
|
bool m_clampToIntegers;
|
||||||
bool m_showValues;
|
bool m_showValues;
|
||||||
|
|
||||||
SliderParams(const char* name, btScalar* targetValuePointer)
|
SliderParams(const char* name, btScalar* targetValuePointer)
|
||||||
@ -26,6 +27,7 @@ struct SliderParams
|
|||||||
m_paramValuePointer(targetValuePointer),
|
m_paramValuePointer(targetValuePointer),
|
||||||
m_userPointer(0),
|
m_userPointer(0),
|
||||||
m_clampToNotches(true),
|
m_clampToNotches(true),
|
||||||
|
m_clampToIntegers(false),
|
||||||
m_showValues(true)
|
m_showValues(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -552,10 +552,6 @@ struct WalkerFilterCallback : public btOverlapFilterCallback
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void floorNNSliderValue(float notUsed) {
|
|
||||||
gParallelEvaluations = floor(gParallelEvaluations);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NN3DWalkersExample::initPhysics()
|
void NN3DWalkersExample::initPhysics()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -657,8 +653,7 @@ void NN3DWalkersExample::initPhysics()
|
|||||||
SliderParams slider("Parallel evaluations", &gParallelEvaluations);
|
SliderParams slider("Parallel evaluations", &gParallelEvaluations);
|
||||||
slider.m_minVal = 1;
|
slider.m_minVal = 1;
|
||||||
slider.m_maxVal = NUM_WALKERS;
|
slider.m_maxVal = NUM_WALKERS;
|
||||||
slider.m_clampToNotches = false;
|
slider.m_clampToIntegers = true;
|
||||||
slider.m_callback = floorNNSliderValue; // hack to get integer values
|
|
||||||
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
|
||||||
slider);
|
slider);
|
||||||
}
|
}
|
||||||
|
@ -138,19 +138,15 @@ static btScalar gCFMSingularityAvoidance = 0;
|
|||||||
|
|
||||||
//GUI related parameter changing helpers
|
//GUI related parameter changing helpers
|
||||||
|
|
||||||
inline void floorSliderValues(float notUsed) { // floor values that should be ints
|
inline void twxChangePhysicsStepsPerSecond(float physicsStepsPerSecond, void*) { // function to change simulation physics steps per second
|
||||||
gSolverIterations = floor(gSolverIterations);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void twxChangePhysicsStepsPerSecond(float physicsStepsPerSecond) { // function to change simulation physics steps per second
|
|
||||||
gPhysicsStepsPerSecond = physicsStepsPerSecond;
|
gPhysicsStepsPerSecond = physicsStepsPerSecond;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void twxChangeFPS(float framesPerSecond) {
|
inline void twxChangeFPS(float framesPerSecond, void*) {
|
||||||
gFramesPerSecond = framesPerSecond;
|
gFramesPerSecond = framesPerSecond;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void twxChangeERPCFM(float notUsed) { // function to change ERP/CFM appropriately
|
inline void twxChangeERPCFM(float notUsed, void*) { // function to change ERP/CFM appropriately
|
||||||
gChangeErpCfm = true;
|
gChangeErpCfm = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,13 +162,12 @@ inline void changeSolver(int comboboxId, const char* item, void* userPointer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void twxChangeSolverIterations(float notUsed){ // change the solver iterations
|
inline void twxChangeSolverIterations(float notUsed, void* userPtr) { // change the solver iterations
|
||||||
|
|
||||||
floorSliderValues(0); // floor the values set by slider
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void clampToCustomSpeedNotches(float speed) { // function to clamp to custom speed notches
|
inline void clampToCustomSpeedNotches(float speed, void*) { // function to clamp to custom speed notches
|
||||||
double minSpeed = 0;
|
double minSpeed = 0;
|
||||||
double minSpeedDist = SimulationSpeeds::MAX_SPEED;
|
double minSpeedDist = SimulationSpeeds::MAX_SPEED;
|
||||||
for (int i = 0; i < SimulationSpeeds::NUM_SPEEDS; i++) {
|
for (int i = 0; i < SimulationSpeeds::NUM_SPEEDS; i++) {
|
||||||
@ -200,7 +195,7 @@ inline void switchMaximumSpeed(int buttonId, bool buttonState, void* userPointer
|
|||||||
// b3Printf("Run maximum speed %s", gMaximumSpeed?"on":"off");
|
// b3Printf("Run maximum speed %s", gMaximumSpeed?"on":"off");
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void setApplicationTick(float frequency){ // set internal application tick
|
inline void setApplicationTick(float frequency, void*){ // set internal application tick
|
||||||
gApplicationTick = 1000.0f/frequency;
|
gApplicationTick = 1000.0f/frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,7 +378,7 @@ struct NN3DWalkersTimeWarpBase: public CommonRigidBodyBase {
|
|||||||
slider.m_minVal = 0;
|
slider.m_minVal = 0;
|
||||||
slider.m_maxVal = 1000;
|
slider.m_maxVal = 1000;
|
||||||
slider.m_callback = twxChangePhysicsStepsPerSecond;
|
slider.m_callback = twxChangePhysicsStepsPerSecond;
|
||||||
slider.m_clampToNotches = false;
|
slider.m_clampToIntegers = true;
|
||||||
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
|
||||||
slider);
|
slider);
|
||||||
}
|
}
|
||||||
|
@ -28,18 +28,20 @@ template<typename T>
|
|||||||
struct MySliderEventHandler : public Gwen::Event::Handler
|
struct MySliderEventHandler : public Gwen::Event::Handler
|
||||||
{
|
{
|
||||||
SliderParamChangedCallback m_callback;
|
SliderParamChangedCallback m_callback;
|
||||||
|
void* m_userPointer;
|
||||||
Gwen::Controls::TextBox* m_label;
|
Gwen::Controls::TextBox* m_label;
|
||||||
Gwen::Controls::Slider* m_pSlider;
|
Gwen::Controls::Slider* m_pSlider;
|
||||||
char m_variableName[1024];
|
char m_variableName[1024];
|
||||||
T* m_targetValue;
|
T* m_targetValue;
|
||||||
bool m_showValue;
|
bool m_showValue;
|
||||||
|
|
||||||
MySliderEventHandler(const char* varName, Gwen::Controls::TextBox* label, Gwen::Controls::Slider* pSlider,T* target,SliderParamChangedCallback callback)
|
MySliderEventHandler(const char* varName, Gwen::Controls::TextBox* label, Gwen::Controls::Slider* pSlider,T* target, SliderParamChangedCallback callback, void* userPtr)
|
||||||
:m_label(label),
|
:m_label(label),
|
||||||
m_pSlider(pSlider),
|
m_pSlider(pSlider),
|
||||||
m_targetValue(target),
|
m_targetValue(target),
|
||||||
m_showValue(true),
|
m_showValue(true),
|
||||||
m_callback(callback)
|
m_callback(callback),
|
||||||
|
m_userPointer(userPtr)
|
||||||
{
|
{
|
||||||
memcpy(m_variableName,varName,strlen(varName)+1);
|
memcpy(m_variableName,varName,strlen(varName)+1);
|
||||||
}
|
}
|
||||||
@ -55,7 +57,7 @@ struct MySliderEventHandler : public Gwen::Event::Handler
|
|||||||
|
|
||||||
if (m_callback)
|
if (m_callback)
|
||||||
{
|
{
|
||||||
(*m_callback)(v);
|
(*m_callback)(v, m_userPointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -223,12 +225,20 @@ void GwenParameterInterface::registerSliderFloatParameter(SliderParams& params)
|
|||||||
pSlider->SetPos( 10, m_gwenInternalData->m_curYposition );
|
pSlider->SetPos( 10, m_gwenInternalData->m_curYposition );
|
||||||
pSlider->SetSize( 200, 20 );
|
pSlider->SetSize( 200, 20 );
|
||||||
pSlider->SetRange( params.m_minVal, params.m_maxVal);
|
pSlider->SetRange( params.m_minVal, params.m_maxVal);
|
||||||
|
if (params.m_clampToIntegers)
|
||||||
|
{
|
||||||
|
pSlider->SetNotchCount( int( params.m_maxVal - params.m_minVal ) );
|
||||||
|
pSlider->SetClampToNotches( params.m_clampToNotches );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
pSlider->SetNotchCount( 16 );//float(params.m_maxVal-params.m_minVal)/100.f);
|
pSlider->SetNotchCount( 16 );//float(params.m_maxVal-params.m_minVal)/100.f);
|
||||||
pSlider->SetClampToNotches( params.m_clampToNotches );
|
pSlider->SetClampToNotches( params.m_clampToNotches );
|
||||||
|
}
|
||||||
pSlider->SetValue( *params.m_paramValuePointer);//dimensions[i] );
|
pSlider->SetValue( *params.m_paramValuePointer);//dimensions[i] );
|
||||||
char labelName[1024];
|
char labelName[1024];
|
||||||
sprintf(labelName,"%s",params.m_name);//axisNames[0]);
|
sprintf(labelName,"%s",params.m_name);//axisNames[0]);
|
||||||
MySliderEventHandler<btScalar>* handler = new MySliderEventHandler<btScalar>(labelName,label,pSlider,params.m_paramValuePointer,params.m_callback);
|
MySliderEventHandler<btScalar>* handler = new MySliderEventHandler<btScalar>(labelName,label,pSlider,params.m_paramValuePointer,params.m_callback, params.m_userPointer);
|
||||||
handler->m_showValue = params.m_showValues;
|
handler->m_showValue = params.m_showValues;
|
||||||
m_paramInternalData->m_sliderEventHandlers.push_back(handler);
|
m_paramInternalData->m_sliderEventHandlers.push_back(handler);
|
||||||
|
|
||||||
|
@ -69,19 +69,19 @@ struct InclinedPlaneExample : public CommonRigidBodyBase
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void onBoxFrictionChanged(float friction);
|
void onBoxFrictionChanged(float friction, void* userPtr);
|
||||||
|
|
||||||
void onBoxRestitutionChanged(float restitution);
|
void onBoxRestitutionChanged(float restitution, void* userPtr);
|
||||||
|
|
||||||
void onSphereFrictionChanged(float friction);
|
void onSphereFrictionChanged(float friction, void* userPtr);
|
||||||
|
|
||||||
void onSphereRestitutionChanged(float restitution);
|
void onSphereRestitutionChanged(float restitution, void* userPtr);
|
||||||
|
|
||||||
void onRampInclinationChanged(float inclination);
|
void onRampInclinationChanged(float inclination, void* userPtr);
|
||||||
|
|
||||||
void onRampFrictionChanged(float friction);
|
void onRampFrictionChanged(float friction, void* userPtr);
|
||||||
|
|
||||||
void onRampRestitutionChanged(float restitution);
|
void onRampRestitutionChanged(float restitution, void* userPtr);
|
||||||
|
|
||||||
void InclinedPlaneExample::initPhysics()
|
void InclinedPlaneExample::initPhysics()
|
||||||
{
|
{
|
||||||
@ -306,35 +306,35 @@ bool InclinedPlaneExample::keyboardCallback(int key, int state) {
|
|||||||
|
|
||||||
|
|
||||||
// GUI parameter modifiers
|
// GUI parameter modifiers
|
||||||
void onBoxFrictionChanged(float friction){
|
void onBoxFrictionChanged(float friction, void*){
|
||||||
if(gBox){
|
if(gBox){
|
||||||
gBox->setFriction(friction);
|
gBox->setFriction(friction);
|
||||||
// b3Printf("Friction of box changed to %f",friction );
|
// b3Printf("Friction of box changed to %f",friction );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onBoxRestitutionChanged(float restitution){
|
void onBoxRestitutionChanged(float restitution, void*){
|
||||||
if(gBox){
|
if(gBox){
|
||||||
gBox->setRestitution(restitution);
|
gBox->setRestitution(restitution);
|
||||||
//b3Printf("Restitution of box changed to %f",restitution);
|
//b3Printf("Restitution of box changed to %f",restitution);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onSphereFrictionChanged(float friction){
|
void onSphereFrictionChanged(float friction, void*){
|
||||||
if(gSphere){
|
if(gSphere){
|
||||||
gSphere->setFriction(friction);
|
gSphere->setFriction(friction);
|
||||||
//b3Printf("Friction of sphere changed to %f",friction );
|
//b3Printf("Friction of sphere changed to %f",friction );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onSphereRestitutionChanged(float restitution){
|
void onSphereRestitutionChanged(float restitution, void*){
|
||||||
if(gSphere){
|
if(gSphere){
|
||||||
gSphere->setRestitution(restitution);
|
gSphere->setRestitution(restitution);
|
||||||
//b3Printf("Restitution of sphere changed to %f",restitution);
|
//b3Printf("Restitution of sphere changed to %f",restitution);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onRampInclinationChanged(float inclination){
|
void onRampInclinationChanged(float inclination, void*){
|
||||||
if(ramp){
|
if(ramp){
|
||||||
btTransform startTransform;
|
btTransform startTransform;
|
||||||
startTransform.setIdentity();
|
startTransform.setIdentity();
|
||||||
@ -351,14 +351,14 @@ void onRampInclinationChanged(float inclination){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onRampFrictionChanged(float friction){
|
void onRampFrictionChanged(float friction, void*){
|
||||||
if(ramp){
|
if(ramp){
|
||||||
ramp->setFriction(friction);
|
ramp->setFriction(friction);
|
||||||
//b3Printf("Friction of ramp changed to %f \n",friction );
|
//b3Printf("Friction of ramp changed to %f \n",friction );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onRampRestitutionChanged(float restitution){
|
void onRampRestitutionChanged(float restitution, void*){
|
||||||
if(ramp){
|
if(ramp){
|
||||||
ramp->setRestitution(restitution);
|
ramp->setRestitution(restitution);
|
||||||
//b3Printf("Restitution of ramp changed to %f \n",restitution);
|
//b3Printf("Restitution of ramp changed to %f \n",restitution);
|
||||||
|
@ -71,11 +71,9 @@ struct MultiPendulumExample: public CommonRigidBodyBase {
|
|||||||
|
|
||||||
static MultiPendulumExample* mex = NULL; // Handle to the example to access it via functions. Do not use this in your simulation!
|
static MultiPendulumExample* mex = NULL; // Handle to the example to access it via functions. Do not use this in your simulation!
|
||||||
|
|
||||||
void onMultiPendulaLengthChanged(float pendulaLength); // Change the pendula length
|
void onMultiPendulaLengthChanged(float pendulaLength, void*); // Change the pendula length
|
||||||
|
|
||||||
void onMultiPendulaRestitutionChanged(float pendulaRestitution); // change the pendula restitution
|
void onMultiPendulaRestitutionChanged(float pendulaRestitution, void*); // change the pendula restitution
|
||||||
|
|
||||||
void floorMSliderValue(float notUsed); // floor the slider values which should be integers
|
|
||||||
|
|
||||||
void applyMForceWithForceScalar(float forceScalar);
|
void applyMForceWithForceScalar(float forceScalar);
|
||||||
|
|
||||||
@ -85,8 +83,7 @@ void MultiPendulumExample::initPhysics() { // Setup your physics scene
|
|||||||
SliderParams slider("Number of Pendula", &gPendulaQty);
|
SliderParams slider("Number of Pendula", &gPendulaQty);
|
||||||
slider.m_minVal = 1;
|
slider.m_minVal = 1;
|
||||||
slider.m_maxVal = 50;
|
slider.m_maxVal = 50;
|
||||||
slider.m_callback = floorMSliderValue; // hack to get integer values
|
slider.m_clampToIntegers = true;
|
||||||
slider.m_clampToNotches = false;
|
|
||||||
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
|
||||||
slider);
|
slider);
|
||||||
}
|
}
|
||||||
@ -95,8 +92,7 @@ void MultiPendulumExample::initPhysics() { // Setup your physics scene
|
|||||||
SliderParams slider("Number of Displaced Pendula", &gDisplacedPendula);
|
SliderParams slider("Number of Displaced Pendula", &gDisplacedPendula);
|
||||||
slider.m_minVal = 0;
|
slider.m_minVal = 0;
|
||||||
slider.m_maxVal = 49;
|
slider.m_maxVal = 49;
|
||||||
slider.m_callback = floorMSliderValue; // hack to get integer values
|
slider.m_clampToIntegers = true;
|
||||||
slider.m_clampToNotches = false;
|
|
||||||
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
|
||||||
slider);
|
slider);
|
||||||
}
|
}
|
||||||
@ -397,7 +393,7 @@ void MultiPendulumExample::applyPendulumForce(btScalar pendulumForce){
|
|||||||
|
|
||||||
// GUI parameter modifiers
|
// GUI parameter modifiers
|
||||||
|
|
||||||
void onMultiPendulaLengthChanged(float pendulaLength) { // Change the pendula length
|
void onMultiPendulaLengthChanged(float pendulaLength, void*) { // Change the pendula length
|
||||||
if (mex){
|
if (mex){
|
||||||
mex->changePendulaLength(pendulaLength);
|
mex->changePendulaLength(pendulaLength);
|
||||||
}
|
}
|
||||||
@ -405,18 +401,13 @@ void onMultiPendulaLengthChanged(float pendulaLength) { // Change the pendula le
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onMultiPendulaRestitutionChanged(float pendulaRestitution) { // change the pendula restitution
|
void onMultiPendulaRestitutionChanged(float pendulaRestitution, void*) { // change the pendula restitution
|
||||||
if (mex){
|
if (mex){
|
||||||
mex->changePendulaRestitution(pendulaRestitution);
|
mex->changePendulaRestitution(pendulaRestitution);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void floorMSliderValue(float notUsed) { // floor the slider values which should be integers
|
|
||||||
gPendulaQty = floor(gPendulaQty);
|
|
||||||
gDisplacedPendula = floor(gDisplacedPendula);
|
|
||||||
}
|
|
||||||
|
|
||||||
void applyMForceWithForceScalar(float forceScalar) {
|
void applyMForceWithForceScalar(float forceScalar) {
|
||||||
if(mex){
|
if(mex){
|
||||||
btScalar appliedForce = forceScalar * gDisplacementForce;
|
btScalar appliedForce = forceScalar * gDisplacementForce;
|
||||||
|
@ -71,11 +71,9 @@ struct NewtonsCradleExample: public CommonRigidBodyBase {
|
|||||||
|
|
||||||
static NewtonsCradleExample* nex = NULL;
|
static NewtonsCradleExample* nex = NULL;
|
||||||
|
|
||||||
void onPendulaLengthChanged(float pendulaLength); // Change the pendula length
|
void onPendulaLengthChanged(float pendulaLength, void* userPtr); // Change the pendula length
|
||||||
|
|
||||||
void onPendulaRestitutionChanged(float pendulaRestitution); // change the pendula restitution
|
void onPendulaRestitutionChanged(float pendulaRestitution, void* userPtr); // change the pendula restitution
|
||||||
|
|
||||||
void floorSliderValue(float notUsed); // floor the slider values which should be integers
|
|
||||||
|
|
||||||
void applyForceWithForceScalar(float forceScalar);
|
void applyForceWithForceScalar(float forceScalar);
|
||||||
|
|
||||||
@ -85,8 +83,7 @@ void NewtonsCradleExample::initPhysics() {
|
|||||||
SliderParams slider("Number of Pendula", &gPendulaQty);
|
SliderParams slider("Number of Pendula", &gPendulaQty);
|
||||||
slider.m_minVal = 1;
|
slider.m_minVal = 1;
|
||||||
slider.m_maxVal = 50;
|
slider.m_maxVal = 50;
|
||||||
slider.m_callback = floorSliderValue; // hack to get integer values
|
slider.m_clampToIntegers = true;
|
||||||
slider.m_clampToNotches = false;
|
|
||||||
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
|
||||||
slider);
|
slider);
|
||||||
}
|
}
|
||||||
@ -95,8 +92,7 @@ void NewtonsCradleExample::initPhysics() {
|
|||||||
SliderParams slider("Number of Displaced Pendula", &gDisplacedPendula);
|
SliderParams slider("Number of Displaced Pendula", &gDisplacedPendula);
|
||||||
slider.m_minVal = 0;
|
slider.m_minVal = 0;
|
||||||
slider.m_maxVal = 49;
|
slider.m_maxVal = 49;
|
||||||
slider.m_callback = floorSliderValue; // hack to get integer values
|
slider.m_clampToIntegers = true;
|
||||||
slider.m_clampToNotches = false;
|
|
||||||
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
|
||||||
slider);
|
slider);
|
||||||
}
|
}
|
||||||
@ -343,25 +339,19 @@ void NewtonsCradleExample::applyPendulumForce(btScalar pendulumForce){
|
|||||||
|
|
||||||
// GUI parameter modifiers
|
// GUI parameter modifiers
|
||||||
|
|
||||||
void onPendulaLengthChanged(float pendulaLength) {
|
void onPendulaLengthChanged(float pendulaLength, void*) {
|
||||||
if (nex){
|
if (nex){
|
||||||
nex->changePendulaLength(pendulaLength);
|
nex->changePendulaLength(pendulaLength);
|
||||||
//b3Printf("Pendula length changed to %f \n",sliderValue );
|
//b3Printf("Pendula length changed to %f \n",sliderValue );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onPendulaRestitutionChanged(float pendulaRestitution) {
|
void onPendulaRestitutionChanged(float pendulaRestitution, void*) {
|
||||||
if (nex){
|
if (nex){
|
||||||
nex->changePendulaRestitution(pendulaRestitution);
|
nex->changePendulaRestitution(pendulaRestitution);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void floorSliderValue(float notUsed) {
|
|
||||||
gPendulaQty = floor(gPendulaQty);
|
|
||||||
gDisplacedPendula = floor(gDisplacedPendula);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void applyForceWithForceScalar(float forceScalar) {
|
void applyForceWithForceScalar(float forceScalar) {
|
||||||
if(nex){
|
if(nex){
|
||||||
btScalar appliedForce = forceScalar * gDisplacementForce;
|
btScalar appliedForce = forceScalar * gDisplacementForce;
|
||||||
|
@ -105,9 +105,7 @@ struct NewtonsRopeCradleExample : public CommonRigidBodyBase {
|
|||||||
|
|
||||||
static NewtonsRopeCradleExample* nex = NULL;
|
static NewtonsRopeCradleExample* nex = NULL;
|
||||||
|
|
||||||
void onRopePendulaRestitutionChanged(float pendulaRestitution);
|
void onRopePendulaRestitutionChanged(float pendulaRestitution, void*);
|
||||||
|
|
||||||
void floorRSliderValue(float notUsed);
|
|
||||||
|
|
||||||
void applyRForceWithForceScalar(float forceScalar);
|
void applyRForceWithForceScalar(float forceScalar);
|
||||||
|
|
||||||
@ -118,8 +116,7 @@ void NewtonsRopeCradleExample::initPhysics()
|
|||||||
SliderParams slider("Number of Pendula", &gPendulaQty);
|
SliderParams slider("Number of Pendula", &gPendulaQty);
|
||||||
slider.m_minVal = 1;
|
slider.m_minVal = 1;
|
||||||
slider.m_maxVal = 50;
|
slider.m_maxVal = 50;
|
||||||
slider.m_callback = floorRSliderValue; // hack to get integer values
|
slider.m_clampToIntegers = true;
|
||||||
slider.m_clampToNotches = false;
|
|
||||||
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
|
||||||
slider);
|
slider);
|
||||||
}
|
}
|
||||||
@ -128,8 +125,7 @@ void NewtonsRopeCradleExample::initPhysics()
|
|||||||
SliderParams slider("Number of Displaced Pendula", &gDisplacedPendula);
|
SliderParams slider("Number of Displaced Pendula", &gDisplacedPendula);
|
||||||
slider.m_minVal = 0;
|
slider.m_minVal = 0;
|
||||||
slider.m_maxVal = 49;
|
slider.m_maxVal = 49;
|
||||||
slider.m_callback = floorRSliderValue; // hack to get integer values
|
slider.m_clampToIntegers = true;
|
||||||
slider.m_clampToNotches = false;
|
|
||||||
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
|
||||||
slider);
|
slider);
|
||||||
}
|
}
|
||||||
@ -148,8 +144,7 @@ void NewtonsRopeCradleExample::initPhysics()
|
|||||||
SliderParams slider("Rope Resolution", &gRopeResolution);
|
SliderParams slider("Rope Resolution", &gRopeResolution);
|
||||||
slider.m_minVal = 1;
|
slider.m_minVal = 1;
|
||||||
slider.m_maxVal = 20;
|
slider.m_maxVal = 20;
|
||||||
slider.m_clampToNotches = false;
|
slider.m_clampToIntegers = true;
|
||||||
slider.m_callback = floorRSliderValue;
|
|
||||||
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
|
||||||
slider);
|
slider);
|
||||||
}
|
}
|
||||||
@ -357,18 +352,12 @@ void NewtonsRopeCradleExample::applyPendulumForce(btScalar pendulumForce){
|
|||||||
|
|
||||||
// GUI parameter modifiers
|
// GUI parameter modifiers
|
||||||
|
|
||||||
void onRopePendulaRestitutionChanged(float pendulaRestitution) {
|
void onRopePendulaRestitutionChanged(float pendulaRestitution, void*) {
|
||||||
if (nex){
|
if (nex){
|
||||||
nex->changePendulaRestitution(pendulaRestitution);
|
nex->changePendulaRestitution(pendulaRestitution);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void floorRSliderValue(float notUsed) {
|
|
||||||
gPendulaQty = floor(gPendulaQty);
|
|
||||||
gDisplacedPendula = floor(gDisplacedPendula);
|
|
||||||
gRopeResolution = floor(gRopeResolution);
|
|
||||||
}
|
|
||||||
|
|
||||||
void applyRForceWithForceScalar(float forceScalar) {
|
void applyRForceWithForceScalar(float forceScalar) {
|
||||||
if(nex){
|
if(nex){
|
||||||
btScalar appliedForce = forceScalar * gDisplacementForce;
|
btScalar appliedForce = forceScalar * gDisplacementForce;
|
||||||
|
@ -633,7 +633,7 @@ void apiSelectButtonCallback(int buttonId, bool buttonState, void* userPointer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setThreadCountCallback(float val)
|
void setThreadCountCallback(float val, void* userPtr)
|
||||||
{
|
{
|
||||||
if (gTaskMgr.getApi()==TaskManager::apiNone)
|
if (gTaskMgr.getApi()==TaskManager::apiNone)
|
||||||
{
|
{
|
||||||
@ -642,7 +642,14 @@ void setThreadCountCallback(float val)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
gTaskMgr.setNumThreads( int( gSliderNumThreads ) );
|
gTaskMgr.setNumThreads( int( gSliderNumThreads ) );
|
||||||
gSliderNumThreads = float(gTaskMgr.getNumThreads());
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setSolverIterationCountCallback(float val, void* userPtr)
|
||||||
|
{
|
||||||
|
if (btDiscreteDynamicsWorld* world = reinterpret_cast<btDiscreteDynamicsWorld*>(userPtr))
|
||||||
|
{
|
||||||
|
world->getSolverInfo().m_numIterations = btMax(1, int(gSliderSolverIterations));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -728,6 +735,15 @@ void CommonRigidBodyMTBase::createDefaultParameters()
|
|||||||
button.m_callback = boolPtrButtonCallback;
|
button.m_callback = boolPtrButtonCallback;
|
||||||
m_guiHelper->getParameterInterface()->registerButtonParameter( button );
|
m_guiHelper->getParameterInterface()->registerButtonParameter( button );
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
SliderParams slider( "Solver iterations", &gSliderSolverIterations );
|
||||||
|
slider.m_minVal = 1.0f;
|
||||||
|
slider.m_maxVal = 30.0f;
|
||||||
|
slider.m_callback = setSolverIterationCountCallback;
|
||||||
|
slider.m_userPointer = m_dynamicsWorld;
|
||||||
|
slider.m_clampToIntegers = true;
|
||||||
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter( slider );
|
||||||
|
}
|
||||||
if (m_multithreadedWorld)
|
if (m_multithreadedWorld)
|
||||||
{
|
{
|
||||||
// create a button for each supported threading API
|
// create a button for each supported threading API
|
||||||
@ -750,7 +766,7 @@ void CommonRigidBodyMTBase::createDefaultParameters()
|
|||||||
slider.m_minVal = 1.0f;
|
slider.m_minVal = 1.0f;
|
||||||
slider.m_maxVal = float(gTaskMgr.getMaxNumThreads()*2);
|
slider.m_maxVal = float(gTaskMgr.getMaxNumThreads()*2);
|
||||||
slider.m_callback = setThreadCountCallback;
|
slider.m_callback = setThreadCountCallback;
|
||||||
slider.m_clampToNotches = false;
|
slider.m_clampToIntegers = true;
|
||||||
m_guiHelper->getParameterInterface()->registerSliderFloatParameter( slider );
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter( slider );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,18 +98,25 @@ void MultiThreadedDemo::initPhysics()
|
|||||||
|
|
||||||
m_dynamicsWorld->setGravity( btVector3( 0, -10, 0 ) );
|
m_dynamicsWorld->setGravity( btVector3( 0, -10, 0 ) );
|
||||||
|
|
||||||
|
{
|
||||||
|
SliderParams slider( "Stack height", &gSliderStackHeight );
|
||||||
|
slider.m_minVal = 1.0f;
|
||||||
|
slider.m_maxVal = 30.0f;
|
||||||
|
slider.m_clampToIntegers = true;
|
||||||
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter( slider );
|
||||||
|
}
|
||||||
{
|
{
|
||||||
SliderParams slider( "Stack rows", &gSliderStackRows );
|
SliderParams slider( "Stack rows", &gSliderStackRows );
|
||||||
slider.m_minVal = 1.0f;
|
slider.m_minVal = 1.0f;
|
||||||
slider.m_maxVal = 20.0f;
|
slider.m_maxVal = 20.0f;
|
||||||
slider.m_clampToNotches = false;
|
slider.m_clampToIntegers = true;
|
||||||
m_guiHelper->getParameterInterface()->registerSliderFloatParameter( slider );
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter( slider );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
SliderParams slider( "Stack columns", &gSliderStackColumns );
|
SliderParams slider( "Stack columns", &gSliderStackColumns );
|
||||||
slider.m_minVal = 1.0f;
|
slider.m_minVal = 1.0f;
|
||||||
slider.m_maxVal = 20.0f;
|
slider.m_maxVal = 20.0f;
|
||||||
slider.m_clampToNotches = false;
|
slider.m_clampToIntegers = true;
|
||||||
m_guiHelper->getParameterInterface()->registerSliderFloatParameter( slider );
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter( slider );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user