//----[ update ]------------------------------------------------------------- void Fluid::update(MapManager* map, int center_x, int center_y, const TileVisibility* visibility, bool visible_areas_valid[2], const VisibleTilesRect::Area new_visible_areas[2]) { bool fluid_changed_or_is_visible = false; if (visible_areas_valid[0]) { fluid_changed_or_is_visible = updateCachedTextures(false, map, &new_visible_areas[0]); } if (visible_areas_valid[1]) { fluid_changed_or_is_visible |= updateCachedTextures(fluid_changed_or_is_visible, map, &new_visible_areas[1]); } // For much of the map there is no fluid at all. If this is the case, there is // no need to lock the buffers, update colors or do any other processing. if (fluid_changed_or_is_visible) { int first_visible_column = center_x - VISIBLE_HORIZONTAL_EXTENT; int first_visible_row = center_y - VISIBLE_VERTICAL_EXTENT; // Rewrite the fluid's colors based on which can be seen TerrainVertex* vertices = NULL; if (lockVB(first_visible_column, first_visible_row, visibility, &vertices)) { if (visible_areas_valid[0]) writeVertices(&new_visible_areas[0], vertices); if (visible_areas_valid[1]) writeVertices(&new_visible_areas[1], vertices); unlockVB(); } // Write the batches updateIB(first_visible_column, first_visible_row, visibility); } }
bool FloraRenderer::preLock() { MF_ASSERT( pLocked_ == NULL ); pLocked_ = lockVB(); return ( pLocked_ ? true : false ); }