From b0cee37e581a20c06ff8225fde8b8de95f68d09e Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sat, 7 Jan 2017 16:25:57 -0800 Subject: sparkler: prefer *.5 to / 2 Multiplies tend to be less costly --- modules/sparkler/bsp.c | 12 ++++++------ modules/sparkler/particles.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/sparkler/bsp.c b/modules/sparkler/bsp.c index 6544993..5e23961 100644 --- a/modules/sparkler/bsp.c +++ b/modules/sparkler/bsp.c @@ -235,23 +235,23 @@ static inline void _bsp_add_occupant(bsp_t *bsp, bsp_occupant_t *occupant, v3f_t /* XXX: note this is pretty unreadable due to reusing the earlier computed values * where the identical computation is required. */ - bv->octrants[OCT_XR_YR_ZR].center.x = (l->right.x - bv->center.x) / 2 + bv->center.x; - bv->octrants[OCT_XR_YR_ZR].center.y = (l->right.y - bv->center.y) / 2 + bv->center.y; - bv->octrants[OCT_XR_YR_ZR].center.z = (l->right.z - bv->center.z) / 2 + bv->center.z; + bv->octrants[OCT_XR_YR_ZR].center.x = (l->right.x - bv->center.x) * .5f + bv->center.x; + bv->octrants[OCT_XR_YR_ZR].center.y = (l->right.y - bv->center.y) * .5f + bv->center.y; + bv->octrants[OCT_XR_YR_ZR].center.z = (l->right.z - bv->center.z) * .5f + bv->center.z; bv->octrants[OCT_XR_YR_ZL].center.x = bv->octrants[OCT_XR_YR_ZR].center.x; bv->octrants[OCT_XR_YR_ZL].center.y = bv->octrants[OCT_XR_YR_ZR].center.y; - bv->octrants[OCT_XR_YR_ZL].center.z = (bv->center.z - l->left.z) / 2 + l->left.z; + bv->octrants[OCT_XR_YR_ZL].center.z = (bv->center.z - l->left.z) * .5f + l->left.z; bv->octrants[OCT_XR_YL_ZR].center.x = bv->octrants[OCT_XR_YR_ZR].center.x; - bv->octrants[OCT_XR_YL_ZR].center.y = (bv->center.y - l->left.y) / 2 + l->left.y; + bv->octrants[OCT_XR_YL_ZR].center.y = (bv->center.y - l->left.y) * .5f + l->left.y; bv->octrants[OCT_XR_YL_ZR].center.z = bv->octrants[OCT_XR_YR_ZR].center.z; bv->octrants[OCT_XR_YL_ZL].center.x = bv->octrants[OCT_XR_YR_ZR].center.x; bv->octrants[OCT_XR_YL_ZL].center.y = bv->octrants[OCT_XR_YL_ZR].center.y; bv->octrants[OCT_XR_YL_ZL].center.z = bv->octrants[OCT_XR_YR_ZL].center.z; - bv->octrants[OCT_XL_YR_ZR].center.x = (bv->center.x - l->left.x) / 2 + l->left.x; + bv->octrants[OCT_XL_YR_ZR].center.x = (bv->center.x - l->left.x) * .5f + l->left.x; bv->octrants[OCT_XL_YR_ZR].center.y = bv->octrants[OCT_XR_YR_ZR].center.y; bv->octrants[OCT_XL_YR_ZR].center.z = bv->octrants[OCT_XR_YR_ZR].center.z; diff --git a/modules/sparkler/particles.c b/modules/sparkler/particles.c index ee23972..daf60ef 100644 --- a/modules/sparkler/particles.c +++ b/modules/sparkler/particles.c @@ -216,7 +216,7 @@ bsp_t * particles_bsp(particles_t *particles) static inline void _particles_draw(particles_t *particles, list_head_t *list, fb_fragment_t *fragment) { - float w2 = fragment->width / 2, h2 = fragment->height / 2; + float w2 = fragment->width * .5f, h2 = fragment->height * .5f; _particle_t *p; assert(particles); -- cgit v1.2.3