diff options
author | Vito Caputo <vcaputo@gnugeneration.com> | 2017-01-07 16:25:57 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@gnugeneration.com> | 2017-01-07 16:25:57 -0800 |
commit | b0cee37e581a20c06ff8225fde8b8de95f68d09e (patch) | |
tree | 46053b3d5e1e779f7d4e12ada19a6f0c329483c7 | |
parent | 78d9c385ae3a1939e059c674ba5649df99d5615c (diff) |
sparkler: prefer *.5 to / 2
Multiplies tend to be less costly
-rw-r--r-- | modules/sparkler/bsp.c | 12 | ||||
-rw-r--r-- | 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); |