Beispiel #1
0
CSVRender::Object::Object (CSMWorld::Data& data, osg::Group* parentNode,
    const std::string& id, bool referenceable, bool forceBaseToZero)
: mData (data), mBaseNode(0), mSelected(false), mParentNode(parentNode), mResourceSystem(data.getResourceSystem().get()), mForceBaseToZero (forceBaseToZero),
  mScaleOverride (1), mOverrideFlags (0), mSubMode (-1), mMarkerTransparency(0.5f)
{
    mRootNode = new osg::PositionAttitudeTransform;

    mBaseNode = new osg::PositionAttitudeTransform;
    mBaseNode->addCullCallback(new SceneUtil::LightListCallback);

    mOutline = new osgFX::Scribe;

    mBaseNode->setUserData(new ObjectTag(this));

    mRootNode->addChild (mBaseNode);

    parentNode->addChild (mRootNode);

    mRootNode->setNodeMask(Mask_Reference);

    if (referenceable)
    {
        mReferenceableId = id;
    }
    else
    {
        mReferenceId = id;
        mReferenceableId = getReference().mRefID;
    }

    adjustTransform();
    update();
    updateMarker();
}
Beispiel #2
0
CSVRender::Object::Object (CSMWorld::Data& data, osg::Group* parentNode,
    const std::string& id, bool referenceable, bool forceBaseToZero)
: mData (data), mBaseNode(0), mSelected(false), mParentNode(parentNode), mResourceSystem(data.getResourceSystem().get()), mForceBaseToZero (forceBaseToZero)
{
    mBaseNode = new osg::PositionAttitudeTransform;
    mOutline = new osgFX::Scribe;
    mOutline->addChild(mBaseNode);

    mBaseNode->setUserData(new ObjectTag(this));

    parentNode->addChild(mBaseNode);

    // 0x1 reserved for separating cull and update visitors
    mBaseNode->setNodeMask(Element_Reference<<1);

    if (referenceable)
    {
        mReferenceableId = id;
    }
    else
    {
        mReferenceId = id;
        mReferenceableId = getReference().mRefID;
    }

    adjustTransform();
    update();
}
Beispiel #3
0
bool Tobias::solve( size_t max, size_t slot, size_t student ) {
	//std::clog << slot << "," << student << "..." << std::endl;
	if( student == getNames().size() ) {
		slot++;
		student = 0;
	}
	if( avaiableSlots() == 0 || slot >= slots() ) {
		//std::cerr << (*this) << std::endl;
		return isSolved( max );
	}
	//std::clog << "!" << !slotFull( slot, max ) << std::endl;
	//std::clog << ">" << getChoices().at( student * slots() + slot ) << std::endl;
	//std::clog << "+" << !isStudentScheduled( student ) << std::endl;
	if( getReference().at( slot ) && !slotFull( slot, max ) && getChoices().at( student * slots() + slot ) && !isStudentScheduled( student ) ) {
		schedule[ student * slots() + slot ] = true;
		//std::clog << "Trying schedule[" << student << "," << slot << "] = true..." << std::endl;
		if( solve( max, slot, student + 1 ) ) {
			return true;
		}
		schedule[ student * slots() + slot ] = false;
	}
//	else {
		return solve( max, slot, student + 1 );
//	}
	return false;
}
Beispiel #4
0
void OSGLoader::addRoute(const Char8  *szOutNodename,
                         const Char8  *szOutFieldname,
                         const Char8  *szInNodename,
                         const Char8  *szInFieldname)
{
    if(szOutNodename == NULL || szOutFieldname == NULL ||
       szInNodename  == NULL || szInFieldname  == NULL  )
    {
        FWARNING(("addRoute missing params\n"));
    }

    FieldContainer *pSrcNode = getReference(szOutNodename);
    FieldContainer *pDstNode = getReference(szInNodename );

    if(pSrcNode == NULL)
    {
        pSrcNode = resolveFieldPath(szOutNodename, 
                                    boost::bind(&OSGLoader::getReference,
                                                this,
                                                _1));
    }

    AttachmentContainer *pSrc = dynamic_cast<AttachmentContainer *>(pSrcNode);

    if(pSrc == NULL)
    {
        FWARNING(("Unknow src node %s\n", szOutNodename));
        return;
    }

    if(pDstNode == NULL)
    {
        pDstNode = resolveFieldPath(szInNodename, 
                                    boost::bind(&OSGLoader::getReference,
                                                this,
                                                _1));
    }

    if(pDstNode == NULL)
    {
        FWARNING(("Unknow dst node %s\n", szInNodename));
        return;
    }

    addConnection(pSrc,     szOutFieldname,
                  pDstNode, szInFieldname );
}
Beispiel #5
0
void CSVRender::Object::update()
{
    if(!mObject.isNull())
        mPhysics->removePhysicsObject(mBase->getName());

    clear();

    std::string model;
    int error = 0; // 1 referemceanöe does not exist, 2 referenceable does not specify a mesh

    const CSMWorld::RefIdCollection& referenceables = mData.getReferenceables();

    int index = referenceables.searchId (mReferenceableId);

    if (index==-1)
        error = 1;
    else
    {
        /// \todo check for Deleted state (error 1)

        model = referenceables.getData (index,
            referenceables.findColumnIndex (CSMWorld::Columns::ColumnId_Model)).
            toString().toUtf8().constData();

        if (model.empty())
            error = 2;
    }

    if (error)
    {
        Ogre::Entity* entity = mBase->getCreator()->createEntity (Ogre::SceneManager::PT_CUBE);
        entity->setMaterialName("BaseWhite"); /// \todo adjust material according to error
        entity->setVisibilityFlags (Element_Reference);

        mBase->attachObject (entity);
    }
    else
    {
        mObject = NifOgre::Loader::createObjects (mBase, "Meshes\\" + model);
        mObject->setVisibilityFlags (Element_Reference);

        if (mPhysics && !mReferenceId.empty())
        {
            const CSMWorld::CellRef& reference = getReference();

            // position
            Ogre::Vector3 position;
            if (!mForceBaseToZero)
                position = Ogre::Vector3(reference.mPos.pos[0], reference.mPos.pos[1], reference.mPos.pos[2]);

            // orientation
            Ogre::Quaternion xr (Ogre::Radian (-reference.mPos.rot[0]), Ogre::Vector3::UNIT_X);
            Ogre::Quaternion yr (Ogre::Radian (-reference.mPos.rot[1]), Ogre::Vector3::UNIT_Y);
            Ogre::Quaternion zr (Ogre::Radian (-reference.mPos.rot[2]), Ogre::Vector3::UNIT_Z);

            mPhysics->addObject("meshes\\" + model, mBase->getName(), mReferenceId, reference.mScale, position, xr*yr*zr);
        }
    }
}
Beispiel #6
0
void BaseTagHDF5::references(const std::vector<DataArray> &refs_new) {
    while (referenceCount() > 0) {
        removeReference(getReference(0)->id());
    }

    for (const auto &ref : refs_new) {
        addReference(ref.id());
    }
}
Beispiel #7
0
void DirDef::writePathFragment(OutputList &ol) const
{
  if (m_parent)
  {
    m_parent->writePathFragment(ol);
    ol.writeString("&nbsp;/&nbsp;");
  }
  ol.writeObjectLink(getReference(),getOutputFileBase(),0,shortName());
}
    float InterpreterContext::getDistance (const std::string& name, const std::string& id) const
    {
        const MWWorld::Ptr ref2 = getReference (id, false, false);
        // If either actor is in a non-active cell, return a large value (just like vanilla)
        if (ref2.isEmpty())
            return std::numeric_limits<float>().max();

        const MWWorld::Ptr ref = getReference (name, false, false);
        if (ref.isEmpty())
            return std::numeric_limits<float>().max();

        double diff[3];

        const float* const pos1 = ref.getRefData().getPosition().pos;
        const float* const pos2 = ref2.getRefData().getPosition().pos;
        for (int i=0; i<3; ++i)
            diff[i] = pos1[i] - pos2[i];

        return std::sqrt (diff[0]*diff[0] + diff[1]*diff[1] + diff[2]*diff[2]);
    }
Beispiel #9
0
int CellCache::indexOfCell(const std::string &cellName) const
{
	//cellnameは同名も存在できるようだが、ひとまず最初に見つかったものを返すことにする
	for(int i = 0; i < m_refs.size(); ++i){
		const CellRef *ref = getReference(i);
		if(cellName == ref->m_cellname){
			return i;		//名前一致したので返す
		}
	}
	return -1;				//名前一致しなかったとき
}
Beispiel #10
0
    void InterpreterContext::setMemberFloat (const std::string& id, const std::string& name, float value)
    {
        const MWWorld::Ptr ptr = getReference (id, false);

        std::string scriptId = MWWorld::Class::get (ptr).getScript (ptr);

        int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'f');

        ptr.getRefData().setLocals (
            *MWBase::Environment::get().getWorld()->getStore().scripts.find (scriptId));
        ptr.getRefData().getLocals().mFloats[index] = value;
    }
Beispiel #11
0
void CSVRender::Object::setEdited (int flags)
{
    bool discard = mOverrideFlags & ~flags;
    int added = flags & ~mOverrideFlags;

    mOverrideFlags = flags;

    if (added & Override_Position)
        for (int i=0; i<3; ++i)
            mPositionOverride.pos[i] = getReference().mPos.pos[i];

    if (added & Override_Rotation)
        for (int i=0; i<3; ++i)
            mPositionOverride.rot[i] = getReference().mPos.rot[i];

    if (added & Override_Scale)
        mScaleOverride = getReference().mScale;

    if (discard)
        adjustTransform();
}
Beispiel #12
0
    int InterpreterContext::getMemberLong (const std::string& id, const std::string& name) const
    {
        const MWWorld::Ptr ptr = getReference (id, false);

        std::string scriptId = MWWorld::Class::get (ptr).getScript (ptr);

        int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'l');

        ptr.getRefData().setLocals (
            *MWBase::Environment::get().getWorld()->getStore().scripts.find (scriptId));
        return ptr.getRefData().getLocals().mLongs[index];
    }
Beispiel #13
0
void Definition::writePathFragment(OutputList &ol) const
{
  makeResident();
  if (m_impl->outerScope && m_impl->outerScope!=Doxygen::globalScope)
  {
    m_impl->outerScope->writePathFragment(ol);
  }
  ol.writeString("      <li class=\"navelem\">");
  if (isLinkable())
  {
    if (definitionType()==Definition::TypeGroup && ((const GroupDef*)this)->groupTitle())
    {
      ol.writeObjectLink(getReference(),getOutputFileBase(),0,((const GroupDef*)this)->groupTitle());
    }
    else if (definitionType()==Definition::TypePage && !((const PageDef*)this)->title().isEmpty())
    {
      ol.writeObjectLink(getReference(),getOutputFileBase(),0,((const PageDef*)this)->title());
    }
    else if (definitionType()==Definition::TypeClass)
    {
      QCString name = m_impl->localName;
      if (name.right(2)=="-p" || name.right(2)=="-g")
      {
        name = name.left(name.length()-2);
      }
      ol.writeObjectLink(getReference(),getOutputFileBase(),0,name);
    }
    else
    {
      ol.writeObjectLink(getReference(),getOutputFileBase(),0,m_impl->localName);
    }
  }
  else
  {
    ol.startBold();
    ol.docify(m_impl->localName);
    ol.endBold();
  }
  ol.writeString("      </li>\n");
}
Beispiel #14
0
bool BaseTagHDF5::removeReference(const std::string &name_or_id) {
    boost::optional<Group> g = refs_group();
    bool removed = false;

    if (g && hasReference(name_or_id)) {
        shared_ptr<IDataArray> reference = getReference(name_or_id);

        g->removeGroup(reference->id());
        removed = true;
    }

    return removed;
}
cl_int IntelAccelerator::getInfo(cl_accelerator_info_intel paramName,
                                 size_t paramValueSize,
                                 void *paramValue,
                                 size_t *paramValueSizeRet) const {
    cl_int result = CL_SUCCESS;
    size_t ret = 0;

    switch (paramName) {
    case CL_ACCELERATOR_DESCRIPTOR_INTEL: {
        ret = getDescriptorSize();
        result = ::getInfo(paramValue, paramValueSize, getDescriptor(), ret);
    }

    break;

    case CL_ACCELERATOR_REFERENCE_COUNT_INTEL: {
        auto v = getReference();

        ret = sizeof(cl_uint);
        result = ::getInfo(paramValue, paramValueSize, &v, ret);
    }

    break;

    case CL_ACCELERATOR_CONTEXT_INTEL: {
        ret = sizeof(cl_context);
        cl_context ctx = static_cast<cl_context>(pContext);
        result = ::getInfo(paramValue, paramValueSize, &ctx, ret);
    }

    break;

    case CL_ACCELERATOR_TYPE_INTEL: {
        auto v = getTypeId();
        ret = sizeof(cl_accelerator_type_intel);
        result = ::getInfo(paramValue, paramValueSize, &v, ret);
    }

    break;

    default:
        result = CL_INVALID_VALUE;
        break;
    }

    if (paramValueSizeRet) {
        *paramValueSizeRet = ret;
    }

    return result;
}
Beispiel #16
0
ESM::Position CSVRender::Object::getPosition() const
{
    ESM::Position position = getReference().mPos;

    if (mOverrideFlags & Override_Position)
        for (int i=0; i<3; ++i)
            position.pos[i] = mPositionOverride.pos[i];

    if (mOverrideFlags & Override_Rotation)
        for (int i=0; i<3; ++i)
            position.rot[i] = mPositionOverride.rot[i];

    return position;
}
Beispiel #17
0
    float InterpreterContext::getDistance (const std::string& name, const std::string& id) const
    {
        // TODO handle exterior cells (when ref and ref2 are located in different cells)
        const MWWorld::Ptr ref2 = getReference (id, false);

        const MWWorld::Ptr ref = mEnvironment.mWorld->getPtr (name, true);

        double diff[3];

        for (int i=0; i<3; ++i)
            diff[i] = ref.getCellRef().pos.pos[i] - ref2.getCellRef().pos.pos[i];

        return std::sqrt (diff[0]*diff[0] + diff[1]*diff[1] + diff[2]*diff[2]);
    }
Beispiel #18
0
/**
 * Common framework for page replacement, with divergent functions
 * broken out.
 */
void replacePages(const char *refString, int frameCount, char *frameReport, void (*initPageReplacement)(void),
        void (*servicePageFault)(int), int (*getVictimPage)(int *, int), void (*usePage)(int), void (*cleanUp)(void)) {
    // The simulated physical memory.
    int frames[frameCount];
    initializeFrames(frames, frameCount);
    
    // Initialize the frame report.
    strncpy(frameReport, "", 1);
    
    // *** Initialize any needed page replacement data structures.
    initPageReplacement();
    
    // Iterate through the reference string.
    int currentReference = 0;
    int referenceCount = strlen(refString);
    while (currentReference < referenceCount) {
        // First, report on the current state of things.
        appendFrameState(frames, frameCount, frameReport);
        
        // Grab the page reference and see if it's in memory.
        int page = getReference(refString, currentReference);
        if (getPageFrame(page, frames, frameCount) == -1) {
            // *** Page fault; fetch the page.
            servicePageFault(page);
            
            // Allocate a frame.
            int frame = getAvailableFrame(frames, frameCount);
            if (frame == -1) {
                // *** Not enough frames; replace a page.
                int victim = getVictimPage(frames, frameCount);
                frame = getPageFrame(victim, frames, frameCount);
            }
            frames[frame] = page;
        }
        
        // *** "Access" the page.
        usePage(page);

        // Move to the next reference.
        currentReference++;
    }
    
    // Issue one last report, and conclude it.
    appendFrameState(frames, frameCount, frameReport);
    finishFrameReport(frameReport);
    
    // *** Perform any necessary clean-up.
    cleanUp();
}
Beispiel #19
0
    float InterpreterContext::getDistance (const std::string& name, const std::string& id) const
    {
        // TODO handle exterior cells (when ref and ref2 are located in different cells)
        const MWWorld::Ptr ref2 = getReference (id, false);

        const MWWorld::Ptr ref = MWBase::Environment::get().getWorld()->getPtr (name, true);

        double diff[3];

        const float* const pos1 = ref.getRefData().getPosition().pos;
        const float* const pos2 = ref2.getRefData().getPosition().pos;
        for (int i=0; i<3; ++i)
            diff[i] = pos1[i] - pos2[i];

        return std::sqrt (diff[0]*diff[0] + diff[1]*diff[1] + diff[2]*diff[2]);
    }
Beispiel #20
0
void CSVRender::Object::adjustTransform()
{
    if (mReferenceId.empty())
        return;

    const CSMWorld::CellRef& reference = getReference();

    // position
    mBaseNode->setPosition(mForceBaseToZero ? osg::Vec3() : osg::Vec3f(reference.mPos.pos[0], reference.mPos.pos[1], reference.mPos.pos[2]));

    // orientation
    osg::Quat xr (-reference.mPos.rot[0], osg::Vec3f(1,0,0));
    osg::Quat yr (-reference.mPos.rot[1], osg::Vec3f(0,1,0));
    osg::Quat zr (-reference.mPos.rot[2], osg::Vec3f(0,0,1));
    mBaseNode->setAttitude(zr*yr*xr);

    mBaseNode->setScale(osg::Vec3(reference.mScale, reference.mScale, reference.mScale));
}
Beispiel #21
0
void OSGLoader::use(const Char8 *szName)
{
    FieldContainerPtr pUseNode;

    // try to find a container with the given name attachment

    pUseNode = getReference(szName);

    if(pUseNode == NullFC)
    {
        SLOG << "No FieldContainer found with name " << szName << std::endl;
    }
    else
    {
        // assign nodepointer to current sf|mf field
        setFieldContainerValue(pUseNode);
    }
}
Beispiel #22
0
CSVRender::Object::Object (const CSMWorld::Data& data, Ogre::SceneNode *cellNode,
    const std::string& id, bool referenceable, bool forceBaseToZero)
: mData (data), mBase (0), mForceBaseToZero (forceBaseToZero)
{
    mBase = cellNode->createChildSceneNode();

    if (referenceable)
    {
        mReferenceableId = id;
    }
    else
    {
        mReferenceId = id;
        mReferenceableId = getReference().mRefID;
    }

    update();
    adjust();
}
    Locals& InterpreterContext::getMemberLocals (std::string& id, bool global)
    {
        if (global)
        {
            return MWBase::Environment::get().getScriptManager()->getGlobalScripts().
                getLocals (id);
        }
        else
        {
            const MWWorld::Ptr ptr = getReference (id, false);

            id = ptr.getClass().getScript (ptr);

            ptr.getRefData().setLocals (
                *MWBase::Environment::get().getWorld()->getStore().get<ESM::Script>().find (id));

            return ptr.getRefData().getLocals();
        }
    }
Beispiel #24
0
void BaseTagHDF5::references(const std::vector<DataArray> &refs_new) {

    // extract vectors of names from vectors of new & old references
    std::vector<std::string> names_new(refs_new.size());
    transform(refs_new.begin(), refs_new.end(), names_new.begin(), util::toName<DataArray>);
	//FIXME: issue 473
    std::vector<DataArray> refs_old(static_cast<size_t>(referenceCount()));
    for (size_t i = 0; i < refs_old.size(); i++) refs_old[i] = getReference(i);
    std::vector<std::string> names_old(refs_old.size());
    transform(refs_old.begin(), refs_old.end(), names_old.begin(), util::toName<DataArray>);

    // sort them
    std::sort(names_new.begin(), names_new.end());
    std::sort(names_new.begin(), names_new.end());

    // get names only in names_new (add), names only in names_old (remove) & ignore rest
    std::vector<std::string> names_add;
    std::vector<std::string> names_rem;
    std::set_difference(names_new.begin(), names_new.end(), names_old.begin(), names_old.end(),
            std::inserter(names_add, names_add.begin()));
    std::set_difference(names_old.begin(), names_old.end(), names_new.begin(), names_new.end(),
            std::inserter(names_rem, names_rem.begin()));

    // check if all new references exist & add sources
    auto blck = dynamic_pointer_cast<BlockHDF5>(block());
    for (auto name : names_add) {
        if (!blck->hasDataArray(name))
            throw std::runtime_error("One or more data arrays do not exist in this block!");
        addReference(blck->getDataArray(name)->id());
    }
    // remove references
    for (auto name : names_rem) {
        if (!blck->hasDataArray(name))
            removeReference(blck->getDataArray(name)->id());
    }
}
Beispiel #25
0
void CSVRender::Object::adjust()
{
    if (mReferenceId.empty())
        return;

    const CSMWorld::CellRef& reference = getReference();

    // position
    if (!mForceBaseToZero)
        mBase->setPosition (Ogre::Vector3 (
            reference.mPos.pos[0], reference.mPos.pos[1], reference.mPos.pos[2]));

    // orientation
    Ogre::Quaternion xr (Ogre::Radian (-reference.mPos.rot[0]), Ogre::Vector3::UNIT_X);

    Ogre::Quaternion yr (Ogre::Radian (-reference.mPos.rot[1]), Ogre::Vector3::UNIT_Y);

    Ogre::Quaternion zr (Ogre::Radian (-reference.mPos.rot[2]), Ogre::Vector3::UNIT_Z);

    mBase->setOrientation (xr*yr*zr);

    // scale
    mBase->setScale (reference.mScale, reference.mScale, reference.mScale);
}
Beispiel #26
0
 MWWorld::Ptr InterpreterContext::getReference()
 {
     return getReference ("", true);
 }
Beispiel #27
0
 void InterpreterContext::disable (const std::string& id)
 {
     MWWorld::Ptr ref = getReference (id, false);
     mEnvironment.mWorld->disable (ref);
 }
Beispiel #28
0
 bool InterpreterContext::isDisabled (const std::string& id) const
 {
     const MWWorld::Ptr ref = getReference (id, false);
     return !ref.getRefData().isEnabled();
 }
Beispiel #29
0
 void InterpreterContext::disable (const std::string& id)
 {
     MWWorld::Ptr ref = getReference (id, false);
     MWBase::Environment::get().getWorld()->disable (ref);
 }
 inline StoredClass const&
 VectorlikeArray< StoredClass >::safeAt( int const soughtIndex ) const
 // if an element out of range is asked for, this throws an exception.
 {
   return getReference( soughtIndex );
 }