MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / CalcWater

Function CalcWater

Descent3/procedurals.cpp:876–931  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

874 }
875}
876void CalcWater(int handle, int density) {
877 int newh;
878 int count = PROC_SIZE + 1;
879 proc_struct *procedural = GameTextures[handle].procedural;
880
881 int16_t *newptr = (int16_t *)procedural->proc2;
882 int16_t *oldptr = (int16_t *)procedural->proc1;
883
884 int x, y;
885
886 // Do main block
887 for (y = 1; y < (PROC_SIZE - 1); y++, count += 2) {
888 for (x = 1; x < PROC_SIZE - 1; x++, count++) {
889 newh = ((oldptr[count + PROC_SIZE] + oldptr[count - PROC_SIZE] + oldptr[count + 1] + oldptr[count - 1]) >> 1) -
890 newptr[count];
891 newptr[count] = newh - (newh >> density);
892 }
893 }
894 int up, down, left, right;
895 count = 0;
896 for (y = 0; y < PROC_SIZE; y++) {
897 if (y == 0)
898 up = -((PROC_SIZE - 1) * PROC_SIZE);
899 else
900 up = PROC_SIZE;
901 if (y == PROC_SIZE - 1)
902 down = -((PROC_SIZE - 1) * PROC_SIZE);
903 else
904 down = PROC_SIZE;
905 for (x = 0; x < PROC_SIZE; x++, count++) {
906 if ((y != 0 && y != PROC_SIZE - 1) && x != 0 && x != PROC_SIZE - 1) {
907 if (x == 1) {
908 x = PROC_SIZE - 2;
909 count += (PROC_SIZE - 3);
910 }
911 continue;
912 }
913 if (x == 0)
914 left = -(PROC_SIZE - 1);
915 else
916 left = 1;
917
918 if (x == PROC_SIZE - 1)
919 right = -(PROC_SIZE - 1);
920 else
921 right = 1;
922 newh = oldptr[count + down];
923 newh += oldptr[count - up];
924 newh += oldptr[count + right];
925 newh += oldptr[count - left];
926 newh >>= 1;
927 newh -= newptr[count];
928 newptr[count] = newh - (newh >> density);
929 }
930 }
931}
932void DrawWaterNoLight(int handle) {
933 int dx, dy;

Callers 1

EvaluateWaterProceduralFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected