generated from soypat/go-module-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
begin adding pruning; fix icube methods
- Loading branch information
Showing
3 changed files
with
232 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package glrender | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/chewxy/math32" | ||
"github.com/soypat/glgl/math/ms3" | ||
) | ||
|
||
func TestIcube(t *testing.T) { | ||
const tol = 1e-4 | ||
const LVLs = 3 | ||
const RES = 1.0 | ||
const maxdim = RES * (1 << (LVLs - 1)) | ||
bb := ms3.Box{Max: ms3.Vec{X: maxdim, Y: maxdim, Z: maxdim}} | ||
topcube, origin, err := makeICube(bb, RES) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
if origin != (ms3.Vec{}) { | ||
t.Error("expected origin at (0,0,0)") | ||
} | ||
t.Error("truebb", bb) | ||
// bbgot := topcube.box(origin, RES) | ||
subcubes := topcube.octree() | ||
t.Error("top", topcube.lvl, topcube.lvlIdx(), topcube.box(origin, topcube.size(RES)), topcube.size(RES)) | ||
for i, subcube := range subcubes { | ||
subsize := subcube.size(RES) | ||
subbox := subcube.box(origin, subsize) | ||
size := subbox.Size() | ||
if math32.Abs(size.Max()-subsize) > tol || math32.Abs(size.Min()-subsize) > tol { | ||
t.Error("size mismatch", size, subsize) | ||
} | ||
t.Error("sub", subcube.lvl, subcube.lvlIdx(), subbox, subsize) | ||
if (i == 0 || i == 1) && subcube.lvl > 1 { | ||
subcube = subcube.octree()[1] | ||
t.Error("subsub", subcube.lvl, subcube.lvlIdx(), subcube.box(origin, subcube.size(RES)), subcube.size(RES)) | ||
} | ||
} | ||
levels := topcube.lvl | ||
_ = levels | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters