Open qq2225936589 opened 3 years ago
Why?
The original water filter crashed on the windows system
OK, it was difficult to follow because this filter was not integrated into either build system, it was outdated for the current frei0r.hpp
. I did not apply your change to use height+1
. Here is my diff
diff --git a/src/Makefile.am b/src/Makefile.am
index 9e8a9c4..1ef849d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -134,6 +134,7 @@ plugin_LTLIBRARIES = \
value.la \
vertigo.la \
vignette.la \
+ water.la \
xfade0r.la
if HAVE_GAVL
diff --git a/src/filter/CMakeLists.txt b/src/filter/CMakeLists.txt
index fb23e89..d9fd2db 100644
--- a/src/filter/CMakeLists.txt
+++ b/src/filter/CMakeLists.txt
@@ -97,3 +97,4 @@ add_subdirectory (tutorial)
add_subdirectory (twolay0r)
add_subdirectory (vertigo)
add_subdirectory (vignette)
+add_subdirectory (water)
diff --git a/src/filter/water/water.cpp b/src/filter/water/water.cpp
index 1d9a589..6dc53ba 100644
--- a/src/filter/water/water.cpp
+++ b/src/filter/water/water.cpp
@@ -144,11 +144,11 @@ public:
// free(buffer);
}
- virtual void update() {
+ virtual void update(double time, uint32_t* out, const uint32_t* in) {
memcpy(BkGdImage, in, width*height*sizeof(uint32_t));
- water_update();
+ water_update(out);
}
@@ -190,14 +190,14 @@ private:
void water_clear();
void water_distort();
void water_setphysics(double physics);
- void water_update();
+ void water_update(uint32_t *out);
void water_drop(int x, int y);
void water_bigsplash(int x, int y);
void water_surfer();
void water_swirl();
void water_3swirls();
- void DrawWater(int page);
+ void DrawWater(int page, uint32_t* out);
void CalcWater(int npage, int density);
void CalcWaterBigFilter(int npage, int density);
@@ -322,7 +322,7 @@ void Water::water_setphysics(double physics) {
}
}
-void Water::water_update() {
+void Water::water_update(uint32_t* out) {
if(rain) {
raincount++;
@@ -334,7 +334,7 @@ void Water::water_update() {
if(swirl) water_swirl();
if(surfer) water_surfer();
- DrawWater(Hpage);
+ DrawWater(Hpage, out);
CalcWater(Hpage^1, density);
Hpage ^=1 ;
@@ -458,27 +458,30 @@ void Water::water_3swirls() {
}
/* internal physics routines */
-void Water::DrawWater(int page) {
+void Water::DrawWater(int page, uint32_t *out) {
int dx, dy;
int x, y;
- int c;
int offset=geo->w + 1;
+ int newoffset;
+ int maxoffset = geo->w * geo->h;
int *ptr = (int*)&Height[page][0];
for (y = calc_optimization; offset < y; offset += 2) {
for (x = offset+geo->w-2; offset < x; offset++) {
dx = ptr[offset] - ptr[offset+1];
dy = ptr[offset] - ptr[offset+geo->w];
- c = BkGdImage[offset + geo->w*(dy>>3) + (dx>>3)];
-
- out[offset] = c;
+ newoffset = offset + geo->w*(dy>>3) + (dx>>3);
+ if (newoffset < maxoffset) {
+ out[offset] = BkGdImage[newoffset];
+ }
offset++;
dx = ptr[offset] - ptr[offset+1];
dy = ptr[offset] - ptr[offset+geo->w];
- c = BkGdImage[offset + geo->w*(dy>>3) + (dx>>3)];
-
- out[offset] = c;
+ newoffset = offset + geo->w*(dy>>3) + (dx>>3);
+ if (newoffset < maxoffset) {
+ out[offset] = BkGdImage[newoffset];
+ }
}
}
}
This code is not ready to be integrated into build at this time. There is a bunch of unused code, unused parameters, and uninitialized variables.
I don't know how to submit the code `
Please check the link below for the complete code
https://github.com/qq2225936589/frei0r_win32/blob/master/water.cpp