void WorldMap::updateFluids() { vector <int> tempList = mChangedList; mChangedList.clear (); for (size_t i = 0; i < tempList.size (); i++) { updateFluid (tempList[i]); // printf ("updating fluid %d, %d\n", i, tempList[i]); } }
//-------------------------------------------------------------- void ofApp::update(){ mixShader.load("mixShader"); accumShader.load("leakyAccum"); updateFluid(); ofSetWindowTitle(ofToString(ofGetFrameRate())); }
// Physics loop bool Physics::update() { if (!enabled) { return true; } // Check if needs to be updated if (simList.empty()) { return true; } std::set<vec> changed; //if(this->lasttime == NULL) this->lasttime = 0; clock_t diffTime = clock() - lasttime; LOG(INFO, "Physics", "Simulating " + dtos(simList.size()) + " items!"); uint32_t listSize = simList.size(); for (uint32_t simIt = 0; simIt < listSize; simIt++) { //Get Pos vec pos = simList[simIt].blocks[0].pos; //Render the block? bool render = simList[simIt].blocks[0].render; //Meta -> High of water(0-7), State of redstone (15-0) uint8_t block, meta; Mineserver::get()->map(map)->getBlock(pos, &block, &meta); if(isWaterBlock(block) || (isLavaBlock(block) && diffTime > 4000)) { updateFluid(simIt); changed.insert(pos); } else if(isRedstone(block)) { updateRedstone(simIt); changed.insert(pos); } else { removeSimulation(pos); uint8_t around[6][2]; vec vectors[6]; getBlocksAround(pos, vectors, around); for(int i = 0; i < 5; i ++) { addSimulation(vectors[i]); } break; } } Mineserver::get()->map(map)->sendMultiBlocks(changed); lasttime = clock(); //clock_t endtime = clock() - starttime; // LOG(INFO, "Physics", "Exit simulation, took " + dtos(endtime * 1000 / CLOCKS_PER_SEC) + " ms, " + dtos(simList.size()) + " items left"); return true; }