static FUNC_UNUSED obj_udata *obj_udata_luacheck_internal(lua_State *L, int _index, void **obj, obj_type *type, int not_delete) { obj_udata *ud; base_caster_t caster = NULL; /* make sure it's a userdata value. */ ud = (obj_udata *)lua_touserdata(L, _index); if(ud != NULL) { /* check object type by comparing metatables. */ if(lua_getmetatable(L, _index)) { if(obj_udata_is_compatible(L, ud, obj, &(caster), type)) { lua_pop(L, 2); /* pop both metatables. */ /* apply caster function if needed. */ if(caster != NULL && *obj != NULL) { caster(obj); } /* check object pointer. */ if(*obj == NULL) { if(not_delete) { luaL_error(L, "null %s", type->name); /* object was garbage collected? */ } return NULL; } return ud; } } } if(not_delete) { luaL_typerror(L, _index, type->name); /* is not a userdata value. */ } return NULL; }
vnl_quaternion<double> Transform::GetVnlDoubleQuaternion() const { mitk::Quaternion fOrientation = this->GetOrientation(); vnl_quaternion<double> dOrientation; VnlVectorFixedCaster<mitk::ScalarType, double, 4> caster( &fOrientation, &dOrientation ); caster.Update(); return dOrientation; }
void Transform::SetTranslation( const vnl_vector<double>& transl) { vnl_vector_fixed<double, 3> dTransl(transl); vnl_vector_fixed<mitk::ScalarType, 3> fTransl; VnlVectorFixedCaster<double, mitk::ScalarType, 3> caster( &dTransl, &fTransl ); caster.Update(); this->SetTranslation( fTransl ); }
vnl_vector_fixed<double, 3> Transform::GetVnlDoubleTranslation() const { vnl_vector_fixed<mitk::ScalarType, 3> vecFloat = this->GetVnlTranslation(); vnl_vector_fixed<double, 3> vecDouble; VnlVectorFixedCaster<mitk::ScalarType, double, 3> caster( &vecFloat, &vecDouble ); caster.Update(); return vecDouble; }
void Transform::SetOrientation( const vnl_quaternion<double>& orientation) { vnl_vector_fixed<mitk::ScalarType, 4> qvec; VnlVectorFixedCaster<double, mitk::ScalarType, 4> caster( &orientation, &qvec ); caster.Update(); mitk::Quaternion p( qvec ); this->SetOrientation( p ); }
static FUNC_UNUSED obj_udata *obj_udata_luacheck_internal(lua_State *L, int _index, void **obj, obj_type *type, int not_delete) { obj_udata *ud; base_caster_t caster = NULL; /* make sure it's a userdata value. */ ud = (obj_udata *)lua_touserdata(L, _index); if(ud != NULL) { /* check object type by comparing metatables. */ if(lua_getmetatable(L, _index)) { if(obj_udata_is_compatible(L, ud, obj, &(caster), type)) { lua_pop(L, 2); /* pop both metatables. */ /* apply caster function if needed. */ if(caster != NULL && *obj != NULL) { caster(obj); } /* check object pointer. */ if(*obj == NULL) { if(not_delete) { luaL_error(L, "null %s", type->name); /* object was garbage collected? */ } return NULL; } return ud; } } } else if(!lua_isnoneornil(L, _index)) { /* handle cdata. */ /* get private table. */ lua_pushlightuserdata(L, obj_udata_private_key); lua_rawget(L, LUA_REGISTRYINDEX); /* private table. */ /* get cdata type check function from private table. */ lua_pushlightuserdata(L, type); lua_rawget(L, -2); /* check for function. */ if(!lua_isnil(L, -1)) { /* pass cdata value to type checking function. */ lua_pushvalue(L, _index); lua_call(L, 1, 1); if(!lua_isnil(L, -1)) { /* valid type get pointer from cdata. */ lua_pop(L, 2); *obj = *(void **)lua_topointer(L, _index); return ud; } lua_pop(L, 2); } else { lua_pop(L, 1); } } if(not_delete) { luaL_typerror(L, _index, type->name); /* is not a userdata value. */ } return NULL; }
BOOST_INTERPROCESS_NEVER_INLINE #elif defined(NDEBUG) inline #endif void * offset_ptr_to_raw_pointer(const volatile void *this_ptr, std::size_t offset) { typedef pointer_size_t_caster<void*> caster_t; #ifndef BOOST_INTERPROCESS_OFFSET_PTR_BRANCHLESS_TO_PTR if(offset == 1){ return 0; } else{ caster_t caster((void*)this_ptr); return caster_t(caster.size() + offset).pointer(); } #else caster_t caster((void*)this_ptr); return caster_t((caster.size() + offset) & -std::size_t(offset != 1)).pointer(); #endif }
void OsgMainApp::loadDefaultScene() { //Shadows const int ReceivesShadowTraversalMask = 0x1; const int CastsShadowTraversalMask = 0x2; osgShadow::ShadowedScene * shadowedScene = new osgShadow::ShadowedScene; shadowedScene->setReceivesShadowTraversalMask(ReceivesShadowTraversalMask); shadowedScene->setCastsShadowTraversalMask(CastsShadowTraversalMask); _root->addChild(shadowedScene); osg::Group * scene = shadowedScene; osgShadow::ShadowMap * sm = new osgShadow::ShadowMap; shadowedScene->setShadowTechnique(sm); sm->setTextureSize(osg::Vec2s(1024, 1024)); // P1 paddle test::Paddle * paddle = new test::Paddle; paddle->setNodeMask(CastsShadowTraversalMask); PaddleManip->setPaddle(paddle); scene->addChild(paddle); // P2 paddle test::Paddle * paddle2 = new test::Paddle; paddle2->setNodeMask(CastsShadowTraversalMask); paddle2->setPosition(osg::Vec3d(0, 0, 16.5)); scene->addChild(paddle2); // Ball Ball = new test::Ball; Ball->setNodeMask(CastsShadowTraversalMask); Ball->setPaddle1(paddle); Ball->setPaddle2(paddle2); scene->addChild(Ball); // Table test::Table * table = new test::Table; table->setNodeMask(ReceivesShadowTraversalMask); table->setPosition(osg::Vec3d(0, 0, 12)); //osg::Quat tr(osg::DegreesToRadians(-20.0), osg::Vec3d(1, 0, 0)); //table->setAttitude(tr); scene->addChild(table); // Light osg::Light * light = new osg::Light; light->setLightNum(0); light->setQuadraticAttenuation(0.02); light->setConstantAttenuation(0.02); light->setPosition(osg::Vec4d(0, 10, 12, 1)); light->setDirection(osg::Vec3d(0, -1, 0)); light->setAmbient(osg::Vec4d(0, 0, 0, 1)); light->setDiffuse(osg::Vec4d(1, 1, 1, 1)); osg::LightSource * lightSource = new osg::LightSource; lightSource->setLight(light); sm->setLight(lightSource); _root->addChild(lightSource); osg::StateSet * state = _root->getOrCreateStateSet(); lightSource->setStateSetModes(*state, osg::StateAttribute::ON); MaskSetter caster(CastsShadowTraversalMask); scene->accept(caster); MaskSetter receiver(ReceivesShadowTraversalMask); table->accept(receiver); }