fixes to wall and particle floodfill. Wall fill ignores particles and always goes to the edges, while particle fill will only ignore walls it can't exist in, and flood particle erase won't check for walls / edges at all
This commit is contained in:
parent
4f5c453643
commit
a06202c78f
@ -1033,9 +1033,8 @@ int LuaScriptInterface::simulation_floodParts(lua_State * l)
|
|||||||
int y = luaL_optint(l,2,-1);
|
int y = luaL_optint(l,2,-1);
|
||||||
int c = luaL_optint(l,3,luacon_model->GetActiveTool(0)->GetToolID());
|
int c = luaL_optint(l,3,luacon_model->GetActiveTool(0)->GetToolID());
|
||||||
int cm = luaL_optint(l,4,-1);
|
int cm = luaL_optint(l,4,-1);
|
||||||
int bm = luaL_optint(l,5,-1);
|
int flags = luaL_optint(l,5,luacon_sim->replaceModeFlags);
|
||||||
int flags = luaL_optint(l,6,luacon_sim->replaceModeFlags);
|
int ret = luacon_sim->FloodParts(x, y, c, cm, flags);
|
||||||
int ret = luacon_sim->FloodParts(x, y, c, cm, bm, flags);
|
|
||||||
lua_pushinteger(l, ret);
|
lua_pushinteger(l, ret);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1093,12 +1092,11 @@ int LuaScriptInterface::simulation_floodWalls(lua_State * l)
|
|||||||
int x = luaL_optint(l,1,-1);
|
int x = luaL_optint(l,1,-1);
|
||||||
int y = luaL_optint(l,2,-1);
|
int y = luaL_optint(l,2,-1);
|
||||||
int c = luaL_optint(l,3,8);
|
int c = luaL_optint(l,3,8);
|
||||||
int cm = luaL_optint(l,4,-1);
|
int bm = luaL_optint(l,4,-1);
|
||||||
int bm = luaL_optint(l,5,-1);
|
int flags = luaL_optint(l,5,luacon_sim->replaceModeFlags);
|
||||||
int flags = luaL_optint(l,6,luacon_sim->replaceModeFlags);
|
|
||||||
if (c < 0 || c >= UI_WALLCOUNT)
|
if (c < 0 || c >= UI_WALLCOUNT)
|
||||||
return luaL_error(l, "Unrecognised wall id '%d'", c);
|
return luaL_error(l, "Unrecognised wall id '%d'", c);
|
||||||
int ret = luacon_sim->FloodWalls(x, y, c, cm, bm, flags);
|
int ret = luacon_sim->FloodWalls(x, y, c, bm, flags);
|
||||||
lua_pushinteger(l, ret);
|
lua_pushinteger(l, ret);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ void ElementTool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1,
|
|||||||
sim->CreateBox(position1.X, position1.Y, position2.X, position2.Y, toolID);
|
sim->CreateBox(position1.X, position1.Y, position2.X, position2.Y, toolID);
|
||||||
}
|
}
|
||||||
void ElementTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {
|
void ElementTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {
|
||||||
sim->FloodParts(position.X, position.Y, toolID, -1, -1);
|
sim->FloodParts(position.X, position.Y, toolID, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ void WallTool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui
|
|||||||
newFanVelX *= strength;
|
newFanVelX *= strength;
|
||||||
float newFanVelY = (position2.Y-position1.Y)*0.005f;
|
float newFanVelY = (position2.Y-position1.Y)*0.005f;
|
||||||
newFanVelY *= strength;
|
newFanVelY *= strength;
|
||||||
sim->FloodWalls(position1.X, position1.Y, WL_FLOODHELPER, -1, WL_FAN, 0);
|
sim->FloodWalls(position1.X, position1.Y, WL_FLOODHELPER, WL_FAN, 0);
|
||||||
for (int j = 0; j < YRES/CELL; j++)
|
for (int j = 0; j < YRES/CELL; j++)
|
||||||
for (int i = 0; i < XRES/CELL; i++)
|
for (int i = 0; i < XRES/CELL; i++)
|
||||||
if (sim->bmap[j][i] == WL_FLOODHELPER)
|
if (sim->bmap[j][i] == WL_FLOODHELPER)
|
||||||
@ -107,7 +107,7 @@ void WallTool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui
|
|||||||
}
|
}
|
||||||
void WallTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {
|
void WallTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {
|
||||||
if (toolID != WL_STREAM)
|
if (toolID != WL_STREAM)
|
||||||
sim->FloodWalls(position.X, position.Y, toolID, -1, -1);
|
sim->FloodWalls(position.X, position.Y, toolID, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
WindTool::WindTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)):
|
WindTool::WindTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)):
|
||||||
@ -185,7 +185,7 @@ void Element_TESC_Tool::DrawRect(Simulation * sim, Brush * brush, ui::Point posi
|
|||||||
}
|
}
|
||||||
void Element_TESC_Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {
|
void Element_TESC_Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {
|
||||||
int radiusInfo = brush->GetRadius().X*4+brush->GetRadius().Y*4+7;
|
int radiusInfo = brush->GetRadius().X*4+brush->GetRadius().Y*4+7;
|
||||||
sim->FloodParts(position.X, position.Y, toolID | (radiusInfo << 8), -1, -1);
|
sim->FloodParts(position.X, position.Y, toolID | (radiusInfo << 8), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,8 +23,9 @@ void * PreviewModel::updateSaveInfoT(void * obj)
|
|||||||
{
|
{
|
||||||
SaveInfo * tempSave = Client::Ref().GetSave(((threadInfo*)obj)->saveID, ((threadInfo*)obj)->saveDate);
|
SaveInfo * tempSave = Client::Ref().GetSave(((threadInfo*)obj)->saveID, ((threadInfo*)obj)->saveDate);
|
||||||
((threadInfo*)obj)->threadFinished = true;
|
((threadInfo*)obj)->threadFinished = true;
|
||||||
if (((threadInfo*)obj)->previewExited && tempSave)
|
if (((threadInfo*)obj)->previewExited)
|
||||||
{
|
{
|
||||||
|
if (tempSave)
|
||||||
delete tempSave;
|
delete tempSave;
|
||||||
delete obj;
|
delete obj;
|
||||||
}
|
}
|
||||||
@ -52,12 +53,15 @@ void * PreviewModel::updateSaveCommentsT(void * obj)
|
|||||||
{
|
{
|
||||||
std::vector<SaveComment*> * tempComments = Client::Ref().GetComments(((threadInfo*)obj)->saveID, (((threadInfo*)obj)->saveDate-1)*20, 20); //saveDate is used as commentsPageNumber
|
std::vector<SaveComment*> * tempComments = Client::Ref().GetComments(((threadInfo*)obj)->saveID, (((threadInfo*)obj)->saveDate-1)*20, 20); //saveDate is used as commentsPageNumber
|
||||||
((threadInfo*)obj)->threadFinished = true;
|
((threadInfo*)obj)->threadFinished = true;
|
||||||
if (((threadInfo*)obj)->previewExited && tempComments)
|
if (((threadInfo*)obj)->previewExited)
|
||||||
|
{
|
||||||
|
if (tempComments)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < tempComments->size(); i++)
|
for(int i = 0; i < tempComments->size(); i++)
|
||||||
delete tempComments->at(i);
|
delete tempComments->at(i);
|
||||||
tempComments->clear();
|
tempComments->clear();
|
||||||
delete tempComments;
|
delete tempComments;
|
||||||
|
}
|
||||||
delete obj;
|
delete obj;
|
||||||
}
|
}
|
||||||
return tempComments;
|
return tempComments;
|
||||||
|
@ -485,8 +485,7 @@ SimulationSample Simulation::GetSample(int x, int y)
|
|||||||
int Simulation::FloodINST(int x, int y, int fullc, int cm)
|
int Simulation::FloodINST(int x, int y, int fullc, int cm)
|
||||||
{
|
{
|
||||||
int c = fullc&0xFF;
|
int c = fullc&0xFF;
|
||||||
int x1, x2, dy = (c<PT_NUM)?1:CELL;
|
int x1, x2;
|
||||||
int co = c;
|
|
||||||
int coord_stack_limit = XRES*YRES;
|
int coord_stack_limit = XRES*YRES;
|
||||||
unsigned short (*coord_stack)[2];
|
unsigned short (*coord_stack)[2];
|
||||||
int coord_stack_size = 0;
|
int coord_stack_size = 0;
|
||||||
@ -522,7 +521,7 @@ int Simulation::FloodINST(int x, int y, int fullc, int cm)
|
|||||||
y = coord_stack[coord_stack_size][1];
|
y = coord_stack[coord_stack_size][1];
|
||||||
x1 = x2 = x;
|
x1 = x2 = x;
|
||||||
// go left as far as possible
|
// go left as far as possible
|
||||||
while (x1>=CELL)
|
while (x1>=0)
|
||||||
{
|
{
|
||||||
if ((pmap[y][x1-1]&0xFF)!=cm || parts[pmap[y][x1-1]>>8].life!=0)
|
if ((pmap[y][x1-1]&0xFF)!=cm || parts[pmap[y][x1-1]>>8].life!=0)
|
||||||
{
|
{
|
||||||
@ -1165,13 +1164,9 @@ void Simulation::CreateWallBox(int x1, int y1, int x2, int y2, int wall, int fla
|
|||||||
CreateWalls(i, j, 0, 0, wall, NULL, flags);
|
CreateWalls(i, j, 0, 0, wall, NULL, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Simulation::FloodWalls(int x, int y, int wall, int cm, int bm, int flags)
|
int Simulation::FloodWalls(int x, int y, int wall, int bm, int flags)
|
||||||
{
|
{
|
||||||
int x1, x2, dy = CELL;
|
int x1, x2, dy = CELL;
|
||||||
if (cm==-1)
|
|
||||||
{
|
|
||||||
cm = pmap[y][x]&0xFF;
|
|
||||||
}
|
|
||||||
if (bm==-1)
|
if (bm==-1)
|
||||||
{
|
{
|
||||||
if (wall==WL_ERASE)
|
if (wall==WL_ERASE)
|
||||||
@ -1186,14 +1181,14 @@ int Simulation::FloodWalls(int x, int y, int wall, int cm, int bm, int flags)
|
|||||||
flags = replaceModeFlags;
|
flags = replaceModeFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pmap[y][x]&0xFF)!=cm || bmap[y/CELL][x/CELL]!=bm || ((flags&SPECIFIC_DELETE) && cm != replaceModeSelected))
|
if (bmap[y/CELL][x/CELL]!=bm)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
// go left as far as possible
|
// go left as far as possible
|
||||||
x1 = x2 = x;
|
x1 = x2 = x;
|
||||||
while (x1>=CELL)
|
while (x1>=CELL)
|
||||||
{
|
{
|
||||||
if ((pmap[y][x1-1]&0xFF)!=cm || bmap[y/CELL][(x1-1)/CELL]!=bm)
|
if (bmap[y/CELL][(x1-1)/CELL]!=bm)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1201,7 +1196,7 @@ int Simulation::FloodWalls(int x, int y, int wall, int cm, int bm, int flags)
|
|||||||
}
|
}
|
||||||
while (x2<XRES-CELL)
|
while (x2<XRES-CELL)
|
||||||
{
|
{
|
||||||
if ((pmap[y][x2+1]&0xFF)!=cm || bmap[y/CELL][(x2+1)/CELL]!=bm)
|
if (bmap[y/CELL][(x2+1)/CELL]!=bm)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1215,15 +1210,15 @@ int Simulation::FloodWalls(int x, int y, int wall, int cm, int bm, int flags)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// fill children
|
// fill children
|
||||||
if (y>=CELL+dy)
|
if (y>=CELL)
|
||||||
for (x=x1; x<=x2; x++)
|
for (x=x1; x<=x2; x++)
|
||||||
if ((pmap[y-dy][x]&0xFF)==cm && bmap[(y-dy)/CELL][x/CELL]==bm)
|
if (bmap[(y-dy)/CELL][x/CELL]==bm)
|
||||||
if (!FloodWalls(x, y-dy, wall, cm, bm, flags))
|
if (!FloodWalls(x, y-dy, wall, bm, flags))
|
||||||
return 0;
|
return 0;
|
||||||
if (y<YRES-CELL-dy)
|
if (y<YRES-CELL)
|
||||||
for (x=x1; x<=x2; x++)
|
for (x=x1; x<=x2; x++)
|
||||||
if ((pmap[y+dy][x]&0xFF)==cm && bmap[(y+dy)/CELL][x/CELL]==bm)
|
if (bmap[(y+dy)/CELL][x/CELL]==bm)
|
||||||
if (!FloodWalls(x, y+dy, wall, cm, bm, flags))
|
if (!FloodWalls(x, y+dy, wall, bm, flags))
|
||||||
return 0;
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1425,11 +1420,10 @@ void Simulation::CreateBox(int x1, int y1, int x2, int y2, int c, int flags)
|
|||||||
CreateParts(i, j, 0, 0, c, flags);
|
CreateParts(i, j, 0, 0, c, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Simulation::FloodParts(int x, int y, int fullc, int cm, int bm, int flags)
|
int Simulation::FloodParts(int x, int y, int fullc, int cm, int flags)
|
||||||
{
|
{
|
||||||
int c = fullc&0xFF;
|
int c = fullc&0xFF;
|
||||||
int x1, x2, dy = (c<PT_NUM)?1:CELL;
|
int x1, x2, dy = (c<PT_NUM)?1:CELL;
|
||||||
int co = c;
|
|
||||||
int coord_stack_limit = XRES*YRES;
|
int coord_stack_limit = XRES*YRES;
|
||||||
unsigned short (*coord_stack)[2];
|
unsigned short (*coord_stack)[2];
|
||||||
int coord_stack_size = 0;
|
int coord_stack_size = 0;
|
||||||
@ -1437,6 +1431,9 @@ int Simulation::FloodParts(int x, int y, int fullc, int cm, int bm, int flags)
|
|||||||
|
|
||||||
if (cm==-1)
|
if (cm==-1)
|
||||||
{
|
{
|
||||||
|
//if initial flood point is out of bounds, do nothing
|
||||||
|
if (c != 0 && (x < CELL || x >= XRES-CELL || y < CELL || y >= YRES-CELL))
|
||||||
|
return 1;
|
||||||
if (c==0)
|
if (c==0)
|
||||||
{
|
{
|
||||||
cm = pmap[y][x]&0xFF;
|
cm = pmap[y][x]&0xFF;
|
||||||
@ -1448,12 +1445,10 @@ int Simulation::FloodParts(int x, int y, int fullc, int cm, int bm, int flags)
|
|||||||
else
|
else
|
||||||
cm = 0;
|
cm = 0;
|
||||||
}
|
}
|
||||||
if (bm==-1)
|
if (IsWallBlocking(x, y, c))
|
||||||
{
|
return 1;
|
||||||
bm = bmap[y/CELL][x/CELL];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FloodFillPmapCheck(x, y, cm) || bmap[y/CELL][x/CELL] != bm )
|
if (!FloodFillPmapCheck(x, y, cm))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
coord_stack = (short unsigned int (*)[2])malloc(sizeof(unsigned short)*2*coord_stack_limit);
|
coord_stack = (short unsigned int (*)[2])malloc(sizeof(unsigned short)*2*coord_stack_limit);
|
||||||
@ -1468,18 +1463,18 @@ int Simulation::FloodParts(int x, int y, int fullc, int cm, int bm, int flags)
|
|||||||
y = coord_stack[coord_stack_size][1];
|
y = coord_stack[coord_stack_size][1];
|
||||||
x1 = x2 = x;
|
x1 = x2 = x;
|
||||||
// go left as far as possible
|
// go left as far as possible
|
||||||
while (x1>=CELL)
|
while (c?x1>CELL:x1>0)
|
||||||
{
|
{
|
||||||
if (!FloodFillPmapCheck(x1-1, y, cm) || bmap[y/CELL][(x1-1)/CELL]!=bm)
|
if (!FloodFillPmapCheck(x1-1, y, cm) || (c != 0 && IsWallBlocking(x1-1, y, c)))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
x1--;
|
x1--;
|
||||||
}
|
}
|
||||||
// go right as far as possible
|
// go right as far as possible
|
||||||
while (x2<XRES-CELL)
|
while (c?x2<XRES-CELL-1:x2<XRES-1)
|
||||||
{
|
{
|
||||||
if (!FloodFillPmapCheck(x2+1, y, cm) || bmap[y/CELL][(x2+1)/CELL]!=bm)
|
if (!FloodFillPmapCheck(x2+1, y, cm) || (c != 0 && IsWallBlocking(x2+1, y, c)))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1492,9 +1487,9 @@ int Simulation::FloodParts(int x, int y, int fullc, int cm, int bm, int flags)
|
|||||||
created_something = 1;
|
created_something = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y>=CELL+dy)
|
if (c?y>=CELL+dy:y>=dy)
|
||||||
for (x=x1; x<=x2; x++)
|
for (x=x1; x<=x2; x++)
|
||||||
if (FloodFillPmapCheck(x, y-dy, cm) && bmap[(y-dy)/CELL][x/CELL]==bm)
|
if (FloodFillPmapCheck(x, y-dy, cm) && (c == 0 || !IsWallBlocking(x, y-dy, c)))
|
||||||
{
|
{
|
||||||
coord_stack[coord_stack_size][0] = x;
|
coord_stack[coord_stack_size][0] = x;
|
||||||
coord_stack[coord_stack_size][1] = y-dy;
|
coord_stack[coord_stack_size][1] = y-dy;
|
||||||
@ -1506,9 +1501,9 @@ int Simulation::FloodParts(int x, int y, int fullc, int cm, int bm, int flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y<YRES-CELL-dy)
|
if (c?y<YRES-CELL-dy:y<YRES-dy)
|
||||||
for (x=x1; x<=x2; x++)
|
for (x=x1; x<=x2; x++)
|
||||||
if (FloodFillPmapCheck(x, y+dy, cm) && bmap[(y+dy)/CELL][x/CELL]==bm)
|
if (FloodFillPmapCheck(x, y+dy, cm) && (c == 0 || !IsWallBlocking(x, y+dy, c)))
|
||||||
{
|
{
|
||||||
coord_stack[coord_stack_size][0] = x;
|
coord_stack[coord_stack_size][0] = x;
|
||||||
coord_stack[coord_stack_size][1] = y+dy;
|
coord_stack[coord_stack_size][1] = y+dy;
|
||||||
|
@ -179,7 +179,7 @@ public:
|
|||||||
int CreateWalls(int x, int y, int rx, int ry, int wall, Brush * cBrush = NULL, int flags = -1);
|
int CreateWalls(int x, int y, int rx, int ry, int wall, Brush * cBrush = NULL, int flags = -1);
|
||||||
void CreateWallLine(int x1, int y1, int x2, int y2, int rx, int ry, int wall, Brush * cBrush = NULL, int flags = -1);
|
void CreateWallLine(int x1, int y1, int x2, int y2, int rx, int ry, int wall, Brush * cBrush = NULL, int flags = -1);
|
||||||
void CreateWallBox(int x1, int y1, int x2, int y2, int wall, int flags = -1);
|
void CreateWallBox(int x1, int y1, int x2, int y2, int wall, int flags = -1);
|
||||||
int FloodWalls(int x, int y, int wall, int cm, int bm, int flags = -1);
|
int FloodWalls(int x, int y, int wall, int bm, int flags = -1);
|
||||||
|
|
||||||
//Drawing Particles
|
//Drawing Particles
|
||||||
int CreateParts(int positionX, int positionY, int c, Brush * cBrush, int flags = -1);
|
int CreateParts(int positionX, int positionY, int c, Brush * cBrush, int flags = -1);
|
||||||
@ -188,7 +188,7 @@ public:
|
|||||||
void CreateLine(int x1, int y1, int x2, int y2, int c, Brush * cBrush, int flags = -1);
|
void CreateLine(int x1, int y1, int x2, int y2, int c, Brush * cBrush, int flags = -1);
|
||||||
void CreateLine(int x1, int y1, int x2, int y2, int c);
|
void CreateLine(int x1, int y1, int x2, int y2, int c);
|
||||||
void CreateBox(int x1, int y1, int x2, int y2, int c, int flags = -1);
|
void CreateBox(int x1, int y1, int x2, int y2, int c, int flags = -1);
|
||||||
int FloodParts(int x, int y, int c, int cm, int bm, int flags = -1);
|
int FloodParts(int x, int y, int c, int cm, int flags = -1);
|
||||||
|
|
||||||
|
|
||||||
void GetGravityField(int x, int y, float particleGrav, float newtonGrav, float & pGravX, float & pGravY);
|
void GetGravityField(int x, int y, float particleGrav, float newtonGrav, float & pGravX, float & pGravY);
|
||||||
|
Loading…
Reference in New Issue
Block a user