Reset to the simple summator example to show the more complex LR in different folder

This commit is contained in:
Alejandro Saucedo 2020-09-26 15:27:15 +01:00
parent 2a43d8bb51
commit 63426281fe
3 changed files with 14 additions and 22 deletions

View file

@ -12,22 +12,15 @@ KomputeSummator::KomputeSummator() {
this->_init();
}
void KomputeSummator::add(Array data) {
for (size_t i = 0; i < data.size(); i++) {
assert(var.get_type() == Variant::Type::REAL);
float value = data[i];
// Set the new data in the local device
this->mSecondaryTensor->setData({value});
// Execute recorded sequence
if (std::shared_ptr<kp::Sequence> sq = this->mSequence.lock()) {
sq->eval();
}
else {
throw std::runtime_error("Sequence pointer no longer available");
}
void KomputeSummator::add(float value) {
// Set the new data in the local device
this->mSecondaryTensor->setData({value});
// Execute recorded sequence
if (std::shared_ptr<kp::Sequence> sq = this->mSequence.lock()) {
sq->eval();
}
else {
throw std::runtime_error("Sequence pointer no longer available");
}
}

View file

@ -2,7 +2,6 @@
#include <Godot.hpp>
#include <Node2D.hpp>
#include <Array.hpp>
#include <memory>
@ -16,7 +15,7 @@ private:
public:
KomputeSummator();
void add(Array data);
void add(float value);
void reset();
float get_total() const;

View file

@ -8,10 +8,10 @@ func _ready():
# Use existing node
print($KomputeNode.get_total())
$KomputeNode.add([10.0, 20.0])
$KomputeNode.add(10)
print($KomputeNode.get_total())
$KomputeNode.add([10.0, 20.0])
$KomputeNode.add(10)
print($KomputeNode.get_total())
# Create new instance
@ -21,9 +21,9 @@ func _ready():
print(s.get_total())
# Now we can again send further commands
s.add([10.0, 20.0])
s.add(10)
print(s.get_total())
s.add([10.0, 20.0])
s.add(10)
print(s.get_total())