Word &operator[](Word offset) { #ifdef R_UM_OPT_ENFORCE_LOWLEV_VALIDITY assert(isWithinBounds(offset)); assert(isWritable()); #endif return block_[offset]; }
bool OgreDetourTileCache::buildTile(const int tx, const int ty, InputGeom *inputGeom) { if (! isWithinBounds(tx, ty)) return false; //TODO maybe I want to keep these values up to date /* m_cacheLayerCount = 0; m_cacheCompressedSize = 0; m_cacheRawSize = 0; */ TileCacheData tiles[MAX_LAYERS]; memset(tiles, 0, sizeof(tiles)); int ntiles = rasterizeTileLayers(inputGeom, tx, ty, m_cfg, tiles, MAX_LAYERS); // This is where the tile is built dtStatus status; // I don't know exactly why this can still be multiple tiles (??) (maybe because there could be tiles on multiple layers) for (int i = 0; i < ntiles; ++i) { TileCacheData* tile = &tiles[i]; dtTileCacheLayerHeader* header = (dtTileCacheLayerHeader*)tile->data; // Important: if a tile already exists at this position, first remove the old one or it will not be updated! removeTile( m_tileCache->getTileRef(m_tileCache->getTileAt(header->tx, header->ty,header->tlayer)) ); status = m_tileCache->addTile(tile->data, tile->dataSize, DT_COMPRESSEDTILE_FREE_DATA, 0); // Add compressed tiles to tileCache if (dtStatusFailed(status)) { dtFree(tile->data); tile->data = 0; continue; // TODO maybe return false here? } // TODO this has to be recalculated differently when rebuilding a tile /* m_cacheLayerCount++; m_cacheCompressedSize += tile->dataSize; m_cacheRawSize += calcLayerBufferSize(m_tcparams.width, m_tcparams.height); */ } //TODO add a deferred command for this? // Build navmesh tile from cached tile m_tileCache->buildNavMeshTilesAt(tx,ty, m_recast->m_navMesh); // This immediately builds the tile, without the need of a dtTileCache::update() //TODO update this value? //m_cacheBuildMemUsage = m_talloc->high; // TODO extract debug drawing to a separate class drawDetail(tx, ty); return true; }
bool OgreDetourTileCache::tileExists(int tx, int ty) { if(!isWithinBounds(tx,ty)) return false; dtCompressedTileRef tiles; int nTiles = m_tileCache->getTilesAt(tx, ty, &tiles, 1); // Return wheter a tile exists on some layer at grid position (tx,ty) return nTiles > 0; }
vector<Entity*> SimpleSceneGraph::getEntitiesWithinBounds(const Shape& bounds, const Vector3& position) const { vector<Entity*> entitiesWithinBounds; for (Entity* entity : entities) { if (isWithinBounds(*entity, bounds, position)) { entitiesWithinBounds.push_back(entity); } } for (unsigned int index = 0; index < children.size(); index++) { vector<Entity*> childResult = children[index]->getEntitiesWithinBounds(bounds, position); entitiesWithinBounds.insert(entitiesWithinBounds.end(), childResult.begin(), childResult.end()); } return entitiesWithinBounds; }
bool OgreDetourTileCache::isWithinBounds(Ogre::Vector3 pos) { Ogre::Vector2 tpos = getTileAtPos(pos); return isWithinBounds((int)tpos.x, (int)tpos.y); }
void Button::handleEvent( const Event& theEvent ) { switch(theEvent.getType()) { case EVENT_MOUSEMOVE: { if(isWithinBounds(((EventMouseMove&)theEvent).getPosition())) { if(!mHover) { mHover = true; game->getSoundEngine()->play2DSound(game->getResourceManager()->get("UI_hoversound")); //redraw(); } } else if(mHover) { mHover = false; //redraw(); } break; } case EVENT_MOUSEDOWN: { EventMouseDown event = ((EventMouseDown&)theEvent); if(event.getButton() == GLFW_MOUSE_BUTTON_1) { if(isWithinBounds(event.getPosition())) { if(!mPressed) { mPressed = true; //redraw(); } } } break; } case EVENT_MOUSEUP: { EventMouseUp event = ((EventMouseUp&)theEvent); if(event.getButton() == GLFW_MOUSE_BUTTON_1) { if(isWithinBounds(event.getPosition())) { if(mPressed) { mPressed = false; //redraw(); game->getSoundEngine()->play2DSound(game->getResourceManager()->get("UI_selectsound")); //Let the menu know we have been pressed. trigger(); } } else mPressed = false; } break; } default: break; } }
void Slider::handleEvent( const Event& theEvent ) { //Make sure the position corresponds. //mSliderPosition.setY(mPosition.Y()); switch(theEvent.getType()) { case EVENT_MOUSEMOVE: { if(isWithinBounds(((EventMouseMove&)theEvent).getPosition())) { if(!mHover) { mHover = true; //redraw(); } } else if(mHover) { mHover = false; //redraw(); } if(mPressed) { mTargetPosition = constrain((((EventMouseMove&)theEvent).getPosition().X() - mPinPosition) - (mMenuPosition.X() + mPosition.X()), 0, mLength); if(mCallOnMove) { mJustReleased = false; trigger(); } } break; } case EVENT_MOUSEDOWN: { EventMouseDown event = ((EventMouseDown&)theEvent); if(event.getButton() == GLFW_MOUSE_BUTTON_1) { if(isWithinBounds(event.getPosition())) { if(!mPressed) { mPressed = true; mTouched = true; game->getSoundEngine()->play2DSound(game->getResourceManager()->get("UI_hoversound")); //redraw(); mPinPosition = ((EventMouseMove&)theEvent).getPosition().X() - (mSliderPosition + mPosition.X() + mMenuPosition.X()); } } } break; } case EVENT_MOUSEUP: { EventMouseUp event = ((EventMouseUp&)theEvent); if(event.getButton() == GLFW_MOUSE_BUTTON_1) { //if(isWithinBounds(event.getPosition())) //{ if(mPressed) { mPressed = false; //redraw(); game->getSoundEngine()->play2DSound(game->getResourceManager()->get("UI_hoversound")); //Let the menu know we have been pressed. mJustReleased = true; trigger(); mJustReleased = false; } //} //else //mPressed = false; } break; } default: break; } }