From: Mikko Rasa Date: Thu, 21 Nov 2013 17:41:15 +0000 (+0200) Subject: More efficient picking of terrain nodes X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=6b90a1c8bb9efff7f660e352bf69a02992d620cc;p=r2c2.git More efficient picking of terrain nodes --- diff --git a/source/libr2c2/terrain.cpp b/source/libr2c2/terrain.cpp index e84c7cd..d4f3e41 100644 --- a/source/libr2c2/terrain.cpp +++ b/source/libr2c2/terrain.cpp @@ -132,6 +132,11 @@ Vector Terrain::get_node_position(const NodeCoordinates &c) const Terrain::NodeCoordinates Terrain::get_closest_node(const Ray &ray) const { + Transform reverse_trans = Transform::rotation(rotation, Vector(0, 0, -1))* + Transform::translation(-position); + Ray local_ray = reverse_trans.transform(ray); + + float ts = type.get_tile_size(); NodeCoordinates coords; float closest_dist = -1; for(unsigned y=0; y