less use of SinF and CosF

This commit is contained in:
UnknownShadow200 2019-01-17 15:41:37 +11:00
parent ce39c6ab93
commit 1b557eb5ec
5 changed files with 19 additions and 19 deletions

View File

@ -97,7 +97,7 @@ Vector3 Entity_GetEyePosition(struct Entity* e);
/* (i.e. distance to eye from feet/base of the model) */ /* (i.e. distance to eye from feet/base of the model) */
float Entity_GetEyeHeight(struct Entity* e); float Entity_GetEyeHeight(struct Entity* e);
/* Calculates the transformation matrix applied when rendering the given entity. */ /* Calculates the transformation matrix applied when rendering the given entity. */
void Entity_GetTransform(struct Entity* e, Vector3 pos, Vector3 scale, struct Matrix* m); CC_API void Entity_GetTransform(struct Entity* e, Vector3 pos, Vector3 scale, struct Matrix* m);
void Entity_GetPickingBounds(struct Entity* e, struct AABB* bb); void Entity_GetPickingBounds(struct Entity* e, struct AABB* bb);
/* Gets the current collision bounds of the given entity. */ /* Gets the current collision bounds of the given entity. */
void Entity_GetBounds(struct Entity* e, struct AABB* bb); void Entity_GetBounds(struct Entity* e, struct AABB* bb);

View File

@ -20,8 +20,8 @@ float Math_SqrtF(float x);
float Math_Mod1(float x); float Math_Mod1(float x);
int Math_AbsI(int x); int Math_AbsI(int x);
double Math_Sin(double x); CC_API double Math_Sin(double x);
double Math_Cos(double x); CC_API double Math_Cos(double x);
float Math_SinF(float x); float Math_SinF(float x);
float Math_CosF(float x); float Math_CosF(float x);

View File

@ -109,21 +109,21 @@ static void HeldBlockRenderer_ProjectionChanged(void* obj) {
https://github.com/UnknownShadow200/ClassicalSharp/wiki/Dig-animation-details https://github.com/UnknownShadow200/ClassicalSharp/wiki/Dig-animation-details
*/ */
static void HeldBlockRenderer_DigAnimation(void) { static void HeldBlockRenderer_DigAnimation(void) {
float sinHalfCircle, sinHalfCircleWeird; double sinHalfCircle, sinHalfCircleWeird;
float t, sqrtLerpPI; float t, sqrtLerpPI;
t = held_time / held_period; t = held_time / held_period;
sinHalfCircle = Math_SinF(t * MATH_PI); sinHalfCircle = Math_Sin(t * MATH_PI);
sqrtLerpPI = Math_SqrtF(t) * MATH_PI; sqrtLerpPI = Math_SqrtF(t) * MATH_PI;
held_entity.Position.X -= Math_SinF(sqrtLerpPI) * 0.4f; held_entity.Position.X -= (float)Math_Sin(sqrtLerpPI) * 0.4f;
held_entity.Position.Y += Math_SinF((sqrtLerpPI * 2)) * 0.2f; held_entity.Position.Y += (float)Math_Sin(sqrtLerpPI * 2) * 0.2f;
held_entity.Position.Z -= sinHalfCircle * 0.2f; held_entity.Position.Z -= (float)sinHalfCircle * 0.2f;
sinHalfCircleWeird = Math_SinF(t * t * MATH_PI); sinHalfCircleWeird = Math_Sin(t * t * MATH_PI);
held_entity.RotY -= Math_SinF(sqrtLerpPI) * 80.0f; held_entity.RotY -= (float)Math_Sin(sqrtLerpPI) * 80.0f;
held_entity.HeadY -= Math_SinF(sqrtLerpPI) * 80.0f; held_entity.HeadY -= (float)Math_Sin(sqrtLerpPI) * 80.0f;
held_entity.RotX += sinHalfCircleWeird * 20.0f; held_entity.RotX += (float)sinHalfCircleWeird * 20.0f;
} }
static void HeldBlockRenderer_ResetAnim(bool setLastHeld, double period) { static void HeldBlockRenderer_ResetAnim(bool setLastHeld, double period) {

View File

@ -198,9 +198,9 @@ void Model_DrawRotate(float angleX, float angleY, float angleZ, struct ModelPart
struct ModelVertex* src = &model->vertices[part->Offset]; struct ModelVertex* src = &model->vertices[part->Offset];
VertexP3fT2fC4b* dst = &Models.Vertices[model->index]; VertexP3fT2fC4b* dst = &Models.Vertices[model->index];
float cosX = Math_CosF(-angleX), sinX = Math_SinF(-angleX); float cosX = (float)Math_Cos(-angleX), sinX = (float)Math_Sin(-angleX);
float cosY = Math_CosF(-angleY), sinY = Math_SinF(-angleY); float cosY = (float)Math_Cos(-angleY), sinY = (float)Math_Sin(-angleY);
float cosZ = Math_CosF(-angleZ), sinZ = Math_SinF(-angleZ); float cosZ = (float)Math_Cos(-angleZ), sinZ = (float)Math_Sin(-angleZ);
float t, x = part->RotX, y = part->RotY, z = part->RotZ; float t, x = part->RotX, y = part->RotY, z = part->RotZ;
struct ModelVertex v; struct ModelVertex v;
@ -1374,9 +1374,9 @@ static void SpiderModel_Draw(struct Entity* entity) {
Model_DrawPart(&spider_link); Model_DrawPart(&spider_link);
Model_DrawPart(&spider_end); Model_DrawPart(&spider_end);
rotX = Math_SinF(entity->Anim.WalkTime) * entity->Anim.Swing * MATH_PI; rotX = (float)Math_Sin(entity->Anim.WalkTime) * entity->Anim.Swing * MATH_PI;
rotZ = Math_CosF(entity->Anim.WalkTime * 2) * entity->Anim.Swing * MATH_PI / 16.0f; rotZ = (float)Math_Cos(entity->Anim.WalkTime * 2) * entity->Anim.Swing * MATH_PI / 16.0f;
rotY = Math_SinF(entity->Anim.WalkTime * 2) * entity->Anim.Swing * MATH_PI / 32.0f; rotY = (float)Math_Sin(entity->Anim.WalkTime * 2) * entity->Anim.Swing * MATH_PI / 32.0f;
Models.Rotation = ROTATE_ORDER_XZY; Models.Rotation = ROTATE_ORDER_XZY;
Model_DrawRotate(rotX, quarterPi + rotY, eighthPi + rotZ, &spider_leftLeg, false); Model_DrawRotate(rotX, quarterPi + rotY, eighthPi + rotZ, &spider_leftLeg, false);

View File

@ -30,7 +30,7 @@ static CC_INLINE String String_Init(STRING_REF char* buffer, int length, int cap
} }
/* Counts number of characters until a '\0' is found. */ /* Counts number of characters until a '\0' is found. */
int String_CalcLen(const char* raw, int capacity); CC_API int String_CalcLen(const char* raw, int capacity);
/* Constructs a string from the given arguments, then sets all characters to '\0'. */ /* Constructs a string from the given arguments, then sets all characters to '\0'. */
String String_InitAndClear(STRING_REF char* buffer, int capacity); String String_InitAndClear(STRING_REF char* buffer, int capacity);
/* Constructs a string from a (maybe null terminated) buffer. */ /* Constructs a string from a (maybe null terminated) buffer. */