[Bf-blender-cvs] [b92d78553b1] blender2.8: Cleanup: don't use Blender structs in iTaSC module.
Brecht Van Lommel
noreply at git.blender.org
Fri Apr 13 11:43:34 CEST 2018
Commit: b92d78553b1889ff5bfbea17b35cf8fda586a062
Author: Brecht Van Lommel
Date: Thu Apr 12 15:59:51 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBb92d78553b1889ff5bfbea17b35cf8fda586a062
Cleanup: don't use Blender structs in iTaSC module.
===================================================================
M intern/itasc/FixedObject.hpp
M intern/itasc/MovingFrame.cpp
M intern/itasc/MovingFrame.hpp
M intern/itasc/Scene.cpp
M intern/itasc/Scene.hpp
M intern/itasc/UncontrolledObject.hpp
M intern/itasc/WorldObject.hpp
M source/blender/ikplugin/intern/itasc_plugin.cpp
===================================================================
diff --git a/intern/itasc/FixedObject.hpp b/intern/itasc/FixedObject.hpp
index e768157ed2b..ad26e7cb2d6 100644
--- a/intern/itasc/FixedObject.hpp
+++ b/intern/itasc/FixedObject.hpp
@@ -21,7 +21,7 @@ public:
int addFrame(const std::string& name, const Frame& frame);
- virtual void updateCoordinates(const struct EvaluationContext *eval_ctx, const Timestamp& timestamp) {};
+ virtual void updateCoordinates(const Timestamp& timestamp) {};
virtual int addEndEffector(const std::string& name);
virtual bool finalize();
virtual const Frame& getPose(const unsigned int frameIndex);
diff --git a/intern/itasc/MovingFrame.cpp b/intern/itasc/MovingFrame.cpp
index 83e15bb59d9..90ebe091eb5 100644
--- a/intern/itasc/MovingFrame.cpp
+++ b/intern/itasc/MovingFrame.cpp
@@ -90,7 +90,7 @@ bool MovingFrame::setCallback(MovingFrameCallback _function, void* _param)
return true;
}
-void MovingFrame::updateCoordinates(const struct EvaluationContext *eval_ctx, const Timestamp& timestamp)
+void MovingFrame::updateCoordinates(const Timestamp& timestamp)
{
// don't compute the velocity during substepping, it is assumed constant.
if (!timestamp.substep) {
@@ -98,7 +98,7 @@ void MovingFrame::updateCoordinates(const struct EvaluationContext *eval_ctx, co
if (!timestamp.reiterate) {
cacheAvail = popInternalFrame(timestamp.cacheTimestamp);
if (m_function)
- (*m_function)(eval_ctx, timestamp, m_internalPose, m_nextPose, m_param);
+ (*m_function)(timestamp, m_internalPose, m_nextPose, m_param);
}
// only compute velocity if we have a previous pose
if (cacheAvail && timestamp.interpolate) {
diff --git a/intern/itasc/MovingFrame.hpp b/intern/itasc/MovingFrame.hpp
index 719e06b4bf7..2e9c2f64bd6 100644
--- a/intern/itasc/MovingFrame.hpp
+++ b/intern/itasc/MovingFrame.hpp
@@ -11,12 +11,10 @@
#include "UncontrolledObject.hpp"
#include <vector>
-struct EvaluationContext;
namespace iTaSC{
typedef bool (*MovingFrameCallback)(
- const struct EvaluationContext *eval_ctx,
const Timestamp& timestamp,
const Frame& _current,
Frame& _next,
@@ -30,7 +28,7 @@ public:
bool setFrame(const Frame& frame);
bool setCallback(MovingFrameCallback _function, void* _param);
- virtual void updateCoordinates(const struct EvaluationContext *eval_ctx, const Timestamp& timestamp);
+ virtual void updateCoordinates(const Timestamp& timestamp);
virtual void updateKinematics(const Timestamp& timestamp);
virtual void pushCache(const Timestamp& timestamp);
virtual void initCache(Cache *_cache);
diff --git a/intern/itasc/Scene.cpp b/intern/itasc/Scene.cpp
index 93f316783ba..5768a994970 100644
--- a/intern/itasc/Scene.cpp
+++ b/intern/itasc/Scene.cpp
@@ -257,7 +257,7 @@ bool Scene::getConstraintPose(ConstraintSet* constraint, void *_param, KDL::Fram
return true;
}
-bool Scene::update(const struct EvaluationContext *eval_ctx, double timestamp, double timestep, unsigned int numsubstep, bool reiterate, bool cache, bool interpolate)
+bool Scene::update(double timestamp, double timestep, unsigned int numsubstep, bool reiterate, bool cache, bool interpolate)
{
// we must have valid timestep and timestamp
if (timestamp < KDL::epsilon || timestep < 0.0)
@@ -316,7 +316,7 @@ bool Scene::update(const struct EvaluationContext *eval_ctx, double timestamp, d
}
}
if (os->object->getType()==Object::UnControlled && ((UncontrolledObject*)os->object)->getNrOfCoordinates() != 0) {
- ((UncontrolledObject*)(os->object))->updateCoordinates(eval_ctx, ts);
+ ((UncontrolledObject*)(os->object))->updateCoordinates(ts);
if (!ts.substep) {
// velocity of uncontrolled object remains constant during substepping
project(m_xdot,os->coordinaterange) = ((UncontrolledObject*)(os->object))->getXudot();
diff --git a/intern/itasc/Scene.hpp b/intern/itasc/Scene.hpp
index ebbec561a6e..5ed031b543e 100644
--- a/intern/itasc/Scene.hpp
+++ b/intern/itasc/Scene.hpp
@@ -39,7 +39,7 @@ public:
bool addSolver(Solver* _solver);
bool addCache(Cache* _cache);
bool initialize();
- bool update(const struct EvaluationContext *eval_ctx, double timestamp, double timestep, unsigned int numsubstep=1, bool reiterate=false, bool cache=true, bool interpolate=true);
+ bool update(double timestamp, double timestep, unsigned int numsubstep=1, bool reiterate=false, bool cache=true, bool interpolate=true);
bool setParam(SceneParam paramId, double value);
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
diff --git a/intern/itasc/UncontrolledObject.hpp b/intern/itasc/UncontrolledObject.hpp
index d932974a24d..81445538fa6 100644
--- a/intern/itasc/UncontrolledObject.hpp
+++ b/intern/itasc/UncontrolledObject.hpp
@@ -11,9 +11,6 @@
#include "eigen_types.hpp"
#include "Object.hpp"
-
-struct EvaluationContext;
-
namespace iTaSC{
class UncontrolledObject: public Object {
@@ -29,7 +26,7 @@ public:
virtual void initialize(unsigned int _nu, unsigned int _nf);
virtual const e_matrix& getJu(unsigned int frameIndex) const;
virtual const e_vector& getXudot() const {return m_xudot;}
- virtual void updateCoordinates(const struct EvaluationContext *eval_ctx, const Timestamp& timestamp)=0;
+ virtual void updateCoordinates(const Timestamp& timestamp)=0;
virtual const unsigned int getNrOfCoordinates(){return m_nu;};
virtual const unsigned int getNrOfFrames(){return m_nf;};
diff --git a/intern/itasc/WorldObject.hpp b/intern/itasc/WorldObject.hpp
index 9876090e128..99756dcd684 100644
--- a/intern/itasc/WorldObject.hpp
+++ b/intern/itasc/WorldObject.hpp
@@ -16,7 +16,7 @@ public:
WorldObject();
virtual ~WorldObject();
- virtual void updateCoordinates(const struct EvaluationContext *eval_ctx, const Timestamp& timestamp) {};
+ virtual void updateCoordinates(const Timestamp& timestamp) {};
virtual void updateKinematics(const Timestamp& timestamp) {};
virtual void pushCache(const Timestamp& timestamp) {};
virtual void initCache(Cache *_cache) {};
diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp
index 93460559067..c74cbb252ff 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.cpp
+++ b/source/blender/ikplugin/intern/itasc_plugin.cpp
@@ -90,6 +90,7 @@ typedef void (*ErrorCallback)(const iTaSC::ConstraintValues *values, unsigned in
// one structure for each target in the scene
struct IK_Target {
+ const struct EvaluationContext *eval_ctx;
struct Scene *blscene;
iTaSC::MovingFrame* target;
iTaSC::ConstraintSet* constraint;
@@ -107,6 +108,7 @@ struct IK_Target {
float eeRest[4][4]; //end effector initial pose relative to armature
IK_Target() {
+ eval_ctx = NULL;
blscene = NULL;
target = NULL;
constraint = NULL;
@@ -157,6 +159,7 @@ struct IK_Channel {
};
struct IK_Scene {
+ const struct EvaluationContext *eval_ctx;
struct Scene *blscene;
IK_Scene* next;
int numchan; // number of channel in pchan
@@ -177,6 +180,7 @@ struct IK_Scene {
std::vector<IK_Target*> targets;
IK_Scene() {
+ eval_ctx = NULL;
blscene = NULL;
next = NULL;
channels = NULL;
@@ -542,7 +546,7 @@ static void GetJointRotation(KDL::Rotation& boneRot, int type, double *rot)
}
}
-static bool target_callback(const struct EvaluationContext *eval_ctx, const iTaSC::Timestamp& timestamp, const iTaSC::Frame& current, iTaSC::Frame& next, void *param)
+static bool target_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame& current, iTaSC::Frame& next, void *param)
{
IK_Target *target = (IK_Target *)param;
// compute next target position
@@ -550,7 +554,7 @@ static bool target_callback(const struct EvaluationContext *eval_ctx, const iTaS
bConstraint *constraint = (bConstraint *)target->blenderConstraint;
float tarmat[4][4];
- BKE_constraint_target_matrix_get(eval_ctx, target->blscene, constraint, 0, CONSTRAINT_OBTYPE_OBJECT, target->owner, tarmat, 1.0);
+ BKE_constraint_target_matrix_get(target->eval_ctx, target->blscene, constraint, 0, CONSTRAINT_OBTYPE_OBJECT, target->owner, tarmat, 1.0);
// rootmat contains the target pose in world coordinate
// if enforce is != 1.0, blend the target position with the end effector position
@@ -577,7 +581,7 @@ static bool target_callback(const struct EvaluationContext *eval_ctx, const iTaS
return true;
}
-static bool base_callback(const struct EvaluationContext *eval_ctx, const iTaSC::Timestamp& timestamp, const iTaSC::Frame& current, iTaSC::Frame& next, void *param)
+static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame& current, iTaSC::Frame& next, void *param)
{
IK_Scene *ikscene = (IK_Scene *)param;
// compute next armature base pose
@@ -619,7 +623,7 @@ static bool base_callback(const struct EvaluationContext *eval_ctx, const iTaSC:
IK_Channel &rootchan = ikscene->channels[0];
// get polar target matrix in world space
- BKE_constraint_target_matrix_get(eval_ctx, ikscene->blscene, ikscene->polarConstraint, 1, CONSTRAINT_OBTYPE_OBJECT, ikscene->blArmature, mat, 1.0);
+ BKE_constraint_target_matrix_get(ikscene->eval_ctx, ikscene->blscene, ikscene->polarConstraint, 1, CONSTRAINT_OBTYPE_OBJECT, ikscene->blArmature, mat, 1.0);
// convert to armature space
mul_m4_m4m4(polemat, imat, mat);
// get the target in world space (was computed before as target object are defined before base object)
@@ -1082,6 +1086,7 @@ static IK_Scene *convert_tree(const struct EvaluationContext *eval_ctx, Scene *b
ikscene = new IK_Scene;
ikscene->blscene = blscene;
+ ikscene->eval_ctx = eval_ctx;
arm = new iTaSC::Armature();
scene = new iTaSC::Scene();
ikscene->channels = new IK_Channel[tree->totchannel];
@@ -1397,7 +1402,7 @@ static IK_Scene *convert_tree(const struct EvaluationContext *eval_ctx, Scene *b
// we can now add the armature
// the armature is based on a moving frame.
// initialize with the correct position in case there is no cache
- base_callback(eval_ctx, iTaSC::Timestamp(), iTaSC::F_identity, initPose, ikscene);
+ base_callback(iTaSC::Timestamp(), iTaSC::F_identity, initPose, ikscene);
ikscene->base = new iTaSC::MovingFrame(initPose);
ikscene->base->setCallback(base_callback, ikscene);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list