예제 #1
0
파일: p6.cpp 프로젝트: Cojacfar/Tutorials
	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
			);
		*/
	}
예제 #2
0
파일: p5.cpp 프로젝트: Cojacfar/Tutorials
void forArgs(TF&& mFn, Ts&&... mArgs)
{
	return (void) std::initializer_list<int>
	{
		(
			mFn(std::forward<Ts>(mArgs)),
			0
		)...
	};
}
예제 #3
0
void chain(TF&& mFn, TArgs&&... mArgs)
{
    forArgs(
        [mFn](auto& mCont)
        {
            for(auto& x : mCont) mFn(x);
        },

        std::forward<TArgs>(mArgs)...);
}
예제 #4
0
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;
}
예제 #5
0
파일: util.cpp 프로젝트: BigRoy/Maya-devkit
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;
}
예제 #6
0
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;
}
예제 #7
0
 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);
 }