@@ -219,28 +219,32 @@ void StagePrivate::sendBackward(InterfaceState&& from, const InterfaceState& to,
219219 newSolution (solution);
220220}
221221
222- void StagePrivate::spawn (InterfaceState&& state , const SolutionBasePtr& solution) {
222+ void StagePrivate::spawn (InterfaceState&& from, InterfaceState&& to , const SolutionBasePtr& solution) {
223223 assert (prevEnds () && nextStarts ());
224+
225+ computeCost (from, to, *solution);
224226
225- computeCost (state, state, *solution);
226-
227- if (!storeSolution (solution, nullptr , nullptr ))
227+ if (!storeSolution (solution, &from, &to))
228228 return ; // solution dropped
229229
230- auto from = states_.insert (states_.end (), InterfaceState (state )); // copy
231- auto to = states_.insert (states_.end (), std::move (state ));
230+ auto from_it = states_.insert (states_.end (), InterfaceState (from ));
231+ auto to_it = states_.insert (states_.end (), std::move (to ));
232232
233- solution->setStartState (*from );
234- solution->setEndState (*to );
233+ solution->setStartState (*from_it );
234+ solution->setEndState (*to_it );
235235
236236 if (!solution->isFailure ()) {
237- prevEnds ()->add (*from );
238- nextStarts ()->add (*to );
237+ prevEnds ()->add (*from_it );
238+ nextStarts ()->add (*to_it );
239239 }
240240
241241 newSolution (solution);
242242}
243243
244+ void StagePrivate::spawn (InterfaceState&& state, const SolutionBasePtr& solution) {
245+ spawn (std::move (state), std::move (state), solution); // copy start and end states
246+ }
247+
244248void StagePrivate::connect (const InterfaceState& from, const InterfaceState& to, const SolutionBasePtr& solution) {
245249 computeCost (from, to, *solution);
246250
@@ -688,6 +692,10 @@ void GeneratorPrivate::compute() {
688692Generator::Generator (GeneratorPrivate* impl) : ComputeBase(impl) {}
689693Generator::Generator (const std::string& name) : Generator(new GeneratorPrivate(this , name)) {}
690694
695+ void Generator::spawn (InterfaceState&& from, InterfaceState&& to, SubTrajectory&& t) {
696+ pimpl ()->spawn (std::move (from), std::move (to), std::make_shared<SubTrajectory>(std::move (t)));
697+ }
698+
691699void Generator::spawn (InterfaceState&& state, SubTrajectory&& t) {
692700 pimpl ()->spawn (std::move (state), std::make_shared<SubTrajectory>(std::move (t)));
693701}
@@ -699,7 +707,7 @@ MonitoringGenerator::MonitoringGenerator(const std::string& name, Stage* monitor
699707 : Generator(new MonitoringGeneratorPrivate(this , name)) {
700708 setMonitoredStage (monitored);
701709}
702-
710+
703711void MonitoringGenerator::setMonitoredStage (Stage* monitored) {
704712 auto impl = pimpl ();
705713 if (impl->monitored_ == monitored)
0 commit comments