static void execN(TF&& mFn, const std::tuple<Ts...>& mXs) { // `TNBase` is the base index of the tuple elements // we're going to get. // `Cs...` gets expanded from 0 to the number of arguments // per function call (`N`). mFn ( std::get<TNBase + TNArity>(mXs)... ); // Example expansion of `execN` for the previous // binary function example called with 4 arguments: /* auto fn([](auto x, auto y){ return x + y; }); forNArgs<2> ( fn, 0, 10, 20, 30 ); (execN<0 * 2>(fn, TUPLE{0, 10, 20, 30}), true) // ...expands to... fn ( std::get<0 + 0>(TUPLE{0, 10, 20, 30}), std::get<0 + 1>(TUPLE{0, 10, 20, 30}) ); // ...expands to... fn ( 0, 10 ); (execN<1 * 2>(fn, TUPLE{0, 10, 20, 30}), true) // ...expands to... fn ( std::get<2 + 0>(TUPLE{0, 10, 20, 30}), std::get<2 + 1>(TUPLE{0, 10, 20, 30}) ); // ...expands to... fn ( 20, 30 ); */ }
void forArgs(TF&& mFn, Ts&&... mArgs) { return (void) std::initializer_list<int> { ( mFn(std::forward<Ts>(mArgs)), 0 )... }; }
void chain(TF&& mFn, TArgs&&... mArgs) { forArgs( [mFn](auto& mCont) { for(auto& x : mCont) mFn(x); }, std::forward<TArgs>(mArgs)...); }
bool util::isIntermediate(const MObject & object) { MStatus stat; MFnDagNode mFn(object); MPlug plug = mFn.findPlug("intermediateObject", false, &stat); if (stat == MS::kSuccess && plug.asBool()) return true; else return false; }
MStatus getPlugByName(const MString & objName, const MString & attrName, MPlug & plug) { MObject object = MObject::kNullObj; MStatus status = getObjectByName(objName, object); if (status == MS::kSuccess) { MFnDependencyNode mFn(object, &status); if (status == MS::kSuccess) plug = mFn.findPlug(attrName, &status); } return status; }
bool util::isRenderable(const MObject & object) { MStatus stat; MFnDagNode mFn(object); // templated turned on? return false MPlug plug = mFn.findPlug("template", false, &stat); if (stat == MS::kSuccess && plug.asBool()) return false; // visibility or lodVisibility off? return false plug = mFn.findPlug("visibility", false, &stat); if (stat == MS::kSuccess && !plug.asBool()) { // the value is off. let's check if it has any in-connection, // otherwise, it means it is not animated. MPlugArray arrayIn; plug.connectedTo(arrayIn, true, false, &stat); if (stat == MS::kSuccess && arrayIn.length() == 0) { return false; } } plug = mFn.findPlug("lodVisibility", false, &stat); if (stat == MS::kSuccess && !plug.asBool()) { MPlugArray arrayIn; plug.connectedTo(arrayIn, true, false, &stat); if (stat == MS::kSuccess && arrayIn.length() == 0) { return false; } } // this shape is renderable return true; }
inline void forTypes(TF&& mFn) noexcept { if(mFn(TypeWrapper<T>{}) == ForAction::Continue) forTypes<Ts...>(mFn); }
void Command::execute(const Entity& e, float dt) const { mFn(e, dt); }