ld33_umonster
changeset 9:4f6168f3ca82
dynamic voxel field bounds
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 27 Aug 2015 01:58:26 +0300 |
parents | bed39534d471 |
children | 1b30bd381667 |
files | src/dragon.cc |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-) [+] |
line diff
1.1 --- a/src/dragon.cc Tue Aug 25 02:26:01 2015 +0300 1.2 +++ b/src/dragon.cc Thu Aug 27 01:58:26 2015 +0300 1.3 @@ -44,7 +44,7 @@ 1.4 1.5 msurf = msurf_create(); 1.6 msurf_set_user_data(msurf, this); 1.7 - msurf_set_resolution(msurf, 36, 36, 36); 1.8 + msurf_set_resolution(msurf, 28, 28, 35); 1.9 msurf_set_threshold(msurf, 1.0); 1.10 msurf_eval_func(msurf, mseval); 1.11 msurf_vertex_func(msurf, msvertex); 1.12 @@ -137,8 +137,13 @@ 1.13 1.14 void Dragon::draw() const 1.15 { 1.16 - static float bmin[] = { head_xlim[0] - VOXEL_PAD * 1.2f, head_ylim[0] - VOXEL_PAD, head_pos.z }; 1.17 - static float bmax[] = { head_xlim[1] + VOXEL_PAD * 1.2f, head_ylim[1] + VOXEL_PAD * 2.1f, pos.z + VOXEL_PAD }; 1.18 + float xmin = std::min(head_pos.x, pos.x); 1.19 + float xmax = std::max(head_pos.x, pos.x); 1.20 + float ymin = std::min(head_pos.y, pos.y); 1.21 + float ymax = std::max(head_pos.y, pos.y); 1.22 + 1.23 + float bmin[] = { xmin - VOXEL_PAD * 1.2f, ymin - VOXEL_PAD, head_pos.z }; 1.24 + float bmax[] = { xmax + VOXEL_PAD * 1.2f, ymax + VOXEL_PAD * 2.1f, pos.z + VOXEL_PAD }; 1.25 msurf_set_bounds(msurf, bmin[0], bmin[1], bmin[2], bmax[0], bmax[1], bmax[2]); 1.26 1.27