# HG changeset patch # User John Tsiombikas # Date 1440629906 -10800 # Node ID 4f6168f3ca82f0a07e5a97740490315db51ce6d8 # Parent bed39534d471b8c1136de51a3d1067aad003f3b3 dynamic voxel field bounds diff -r bed39534d471 -r 4f6168f3ca82 src/dragon.cc --- a/src/dragon.cc Tue Aug 25 02:26:01 2015 +0300 +++ b/src/dragon.cc Thu Aug 27 01:58:26 2015 +0300 @@ -44,7 +44,7 @@ msurf = msurf_create(); msurf_set_user_data(msurf, this); - msurf_set_resolution(msurf, 36, 36, 36); + msurf_set_resolution(msurf, 28, 28, 35); msurf_set_threshold(msurf, 1.0); msurf_eval_func(msurf, mseval); msurf_vertex_func(msurf, msvertex); @@ -137,8 +137,13 @@ void Dragon::draw() const { - static float bmin[] = { head_xlim[0] - VOXEL_PAD * 1.2f, head_ylim[0] - VOXEL_PAD, head_pos.z }; - static float bmax[] = { head_xlim[1] + VOXEL_PAD * 1.2f, head_ylim[1] + VOXEL_PAD * 2.1f, pos.z + VOXEL_PAD }; + float xmin = std::min(head_pos.x, pos.x); + float xmax = std::max(head_pos.x, pos.x); + float ymin = std::min(head_pos.y, pos.y); + float ymax = std::max(head_pos.y, pos.y); + + float bmin[] = { xmin - VOXEL_PAD * 1.2f, ymin - VOXEL_PAD, head_pos.z }; + float bmax[] = { xmax + VOXEL_PAD * 1.2f, ymax + VOXEL_PAD * 2.1f, pos.z + VOXEL_PAD }; msurf_set_bounds(msurf, bmin[0], bmin[1], bmin[2], bmax[0], bmax[1], bmax[2]);