@@ -22,10 +22,11 @@ std::optional<Mat::RTMat> InnerEigenAPI::get_transformation_matrix(const std::st
2222{
2323 if ( not DSR::DSRGraph::is_valid_edge_type (edge_type))
2424 return {};
25+ const bool use_cache = (timestamp == 0 );
2526 KeyTransform key = std::make_tuple (dest, orig, edge_type);
26- if ( auto it = cache. find (key) ; it != cache. end () )
27- return it-> second ;
28- else
27+ if (use_cache )
28+ if ( auto it = cache. find (key) ; it != cache. end ())
29+ return it-> second ;
2930 {
3031 Mat::RTMat atotal (Mat::RTMat::Identity ());
3132 Mat::RTMat btotal (Mat::RTMat::Identity ());
@@ -59,7 +60,8 @@ std::optional<Mat::RTMat> InnerEigenAPI::get_transformation_matrix(const std::st
5960 if ( auto rtmat = rt->get_edge_RT_as_rtmat (edge_rt.value (), timestamp); rtmat.has_value ())
6061 {
6162 atotal = rtmat.value () * atotal;
62- node_map[p_node.value ().id ()].push_back (key); // update node cache reference
63+ if (use_cache)
64+ node_map[p_node.value ().id ()].push_back (key); // update node cache reference
6365 a = p_node.value ();
6466 }
6567 else return {};
@@ -79,7 +81,8 @@ std::optional<Mat::RTMat> InnerEigenAPI::get_transformation_matrix(const std::st
7981 if ( auto rtmat = rt->get_edge_RT_as_rtmat (edge_rt.value (), timestamp); rtmat.has_value ())
8082 {
8183 btotal = rtmat.value () * btotal;
82- node_map[p_node.value ().id ()].push_back (key); // update node cache reference
84+ if (use_cache)
85+ node_map[p_node.value ().id ()].push_back (key); // update node cache reference
8386 b = p_node.value ();
8487 }
8588 else
@@ -111,8 +114,11 @@ std::optional<Mat::RTMat> InnerEigenAPI::get_transformation_matrix(const std::st
111114 {
112115 atotal = a_rtmat.value () * atotal;
113116 btotal = b_rtmat.value () * btotal;
114- node_map[p_node.value ().id ()].push_back (key); // update node cache reference
115- node_map[q_node.value ().id ()].push_back (key); // update node cache reference
117+ if (use_cache)
118+ {
119+ node_map[p_node.value ().id ()].push_back (key); // update node cache reference
120+ node_map[q_node.value ().id ()].push_back (key); // update node cache reference
121+ }
116122 a = p_node.value ();
117123 b = q_node.value ();
118124 }
@@ -125,12 +131,15 @@ std::optional<Mat::RTMat> InnerEigenAPI::get_transformation_matrix(const std::st
125131 }
126132 }
127133 // update node cache reference
128- node_map[bn.value ().id ()].push_back (key);
129- node_map[an.value ().id ()].push_back (key);
134+ if (use_cache)
135+ {
136+ node_map[bn.value ().id ()].push_back (key);
137+ node_map[an.value ().id ()].push_back (key);
138+ }
130139
131- // update cache
132140 auto ret = btotal.inverse () * atotal;
133- cache[key] = ret;
141+ if (use_cache)
142+ cache[key] = ret;
134143 return ret;
135144 }
136145}
0 commit comments