Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add Cyclone Tool and Brush X/Y Arguments (#542)
- Loading branch information
Showing
12 changed files
with
62 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include "ToolClasses.h" | ||
#include "simulation/Air.h" | ||
//#TPT-Directive ToolClass Tool_Cycl TOOL_CYCL 8 | ||
Tool_Cycl::Tool_Cycl() | ||
{ | ||
Identifier = "DEFAULT_TOOL_CYCL"; | ||
Name = "CYCL"; | ||
Colour = PIXPACK(0x132f5b); | ||
Description = "Cyclone. Produces swirling air currents"; | ||
} | ||
|
||
int Tool_Cycl::Perform(Simulation * sim, Particle * cpart, int x, int y, int brushX, int brushY, float strength) | ||
{ | ||
/* | ||
Air velocity calculation. | ||
Air velocity X = cosine of cell angle | ||
Angle of cell is calculated via cells X/Y relation to the brush center and arctangent | ||
Angle has 1.57 radians added to it (90 degrees) in order to make the velocity be at 90 degrees to the centerpoint. | ||
Ditto for X, except X uses sine | ||
*/ | ||
// only trigger once per cell (less laggy) | ||
if ((x%CELL) == 0 && (y%CELL) == 0) | ||
{ | ||
float *vx = &sim->air->vx[y/CELL][x/CELL]; | ||
float *vy = &sim->air->vy[y/CELL][x/CELL]; | ||
|
||
*vx -= (strength / 16) * (cos(1.57f + (atan2(brushY - y, brushX - x)))); | ||
*vy -= (strength / 16) * (sin(1.57f + (atan2(brushY - y, brushX - x)))); | ||
|
||
// Clamp velocities | ||
if (*vx > 256.0f) | ||
*vx = 256.0f; | ||
else if (*vx < -256.0f) | ||
*vx = -256.0f; | ||
if (*vy > 256.0f) | ||
*vy = 256.0f; | ||
else if (*vy < -256.0f) | ||
*vy = -256.0f; | ||
|
||
} | ||
|
||
return 1; | ||
} | ||
|
||
Tool_Cycl::~Tool_Cycl() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters