cloth wind rippling

main
cosmonaut 2021-09-30 19:25:38 -07:00
parent 311e263390
commit 5f018e76ba
1 changed files with 9 additions and 2 deletions

View File

@ -351,6 +351,8 @@ typedef struct Silkworm_Context
float yBound;
uint32_t clothDensity;
float timeElapsed;
uint8_t* currentBufferAddress; /* GM doesnt let you pass more than 4 arguments with different types lol */
/* keep track of these so can do callbacks */
@ -403,6 +405,7 @@ void Silkworm_Init()
context->xBound = 1000;
context->yBound = 1000;
context->clothDensity = 4;
context->timeElapsed = 0;
context->nodeDestructionDataCapacity = 16;
context->nodeDestructionData = malloc(sizeof(Silkworm_Vector2) * context->nodeDestructionDataCapacity);
@ -731,6 +734,8 @@ void Silkworm_Update(double deltaTime)
}
Silkworm_PerformDestroys();
context->timeElapsed += delta;
}
double Silkworm_CreateNode(double xPosition, double yPosition, double mass, double friction, double radius, double pushFactor, double windFactor)
@ -1084,8 +1089,8 @@ void Silkworm_ApplyWind(double xSpeed, double ySpeed)
if (node != NULL && !node->pinned)
{
node->position.x += (float)xSpeed * 0.025f * node->windFactor;
node->position.y += (float)ySpeed * 0.025f * node->windFactor;
node->position.x += (0.5f * sinf(context->timeElapsed / 15 + node->position.y / 2) + 0.5f) * (float)xSpeed * 0.05f * node->windFactor;
node->position.y += (0.5f * sinf(context->timeElapsed / 15 + node->position.x / 3) + 0.5f) * (float)ySpeed * 0.05f * node->windFactor;
}
}
}
@ -1977,6 +1982,8 @@ void Silkworm_ClearAll()
}
Silkworm_PerformDestroys();
context->timeElapsed = 0;
}
void Silkworm_Finish()