Skip to content

Commit

Permalink
Merge branch 'release/0.7.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter committed Mar 15, 2015
2 parents f5899bf + 4c8a6b9 commit 9b883bf
Show file tree
Hide file tree
Showing 40 changed files with 751 additions and 354 deletions.
17 changes: 17 additions & 0 deletions doc/release-notes/0.7.8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Antimony 0.7.8
--------------

**Features:**
- Human-readable file format
- Friendlier for version control, manual editing.
- Older files will be automatically upgraded.
- `Set colour HSB` node (thanks, [RobotGrrl](https://github.com/mkeeter/antimony/pull/11))
- Huge speed-up in loading large files (about 20X).
- Minor solver speed-up using `restrict` keyword.

**Bugfixes:**
- Fixed memory leak in applying `Transform` objects.
- Don't spawn huge number of threads when loading complex files.
- If rendering is interrupted, don't leak images.
- Correct interface between `QGraphicsItem` and `OpenGL`.
- Fix *huge* leak of images and `OpenGL` textures.
53 changes: 53 additions & 0 deletions py/nodes/Color/set_color_hsb.node
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import fab

title('Set color (HSB)')

input("shape", fab.types.Shape)
input("hue", float)
input("saturation", float)
input("brightness", float)

# copied from Java's HSBtoRGB
# http://www.docjar.com/html/api/java/awt/Color.java.html

r = 0
g = 0
b = 0

if saturation == 0:
r = g = b = int(brightness * 255.0 + 0.5)
else:
h = (hue - float(math.floor(hue))) * 6.0
f = h - float(math.floor(h))
p = brightness * (1-saturation)
q = brightness * (1-saturation*f)
t = brightness * (1-(saturation*(1-f)))

h = int(h)

if(h==0):
r = int(brightness * 255.0 + 0.5)
g = int(t * 255.0 + 0.5)
b = int(p * 255.0 + 0.5)
elif(h==1):
r = int(q * 255.0 + 0.5)
g = int(brightness * 255.0 + 0.5)
b = int(p * 255.0 + 0.5)
elif(h==2):
r = int(p * 255.0 + 0.5)
g = int(brightness * 255.0 + 0.5)
b = int(t * 255.0 + 0.5)
elif(h==3):
r = int(p * 255.0 + 0.5)
g = int(q * 255.0 + 0.5)
b = int(brightness * 255.0 + 0.5)
elif(h==4):
r = int(t * 255.0 + 0.5)
g = int(p * 255.0 + 0.5)
b = int(brightness * 255.0 + 0.5)
elif(h==5):
r = int(brightness * 255.0 + 0.5)
g = int(p * 255.0 + 0.5)
b = int(q * 255.0 + 0.5)

output("out", fab.shapes.set_color(shape, r, g, b))
2 changes: 2 additions & 0 deletions qt/fab.pri
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ SOURCES += \
../src/fab/formats/png.c \
../src/fab/formats/stl.c \
../src/fab/util/region.c \
../src/fab/util/ustack.c \
../src/fab/types/shape.cpp \
../src/fab/fab.cpp \
../src/fab/types/bounds.cpp \
Expand All @@ -37,6 +38,7 @@ HEADERS += \
../src/fab/formats/png.h \
../src/fab/formats/stl.h \
../src/fab/util/region.h \
../src/fab/util/ustack.h \
../src/fab/types/shape.h \
../src/fab/fab.h \
../src/fab/types/bounds.h \
Expand Down
2 changes: 2 additions & 0 deletions qt/shared.pri
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ SOURCES += \
../src/graph/datum/link.cpp \
../src/graph/node/serializer.cpp \
../src/graph/node/deserializer.cpp \
../src/graph/node/deserializer_old.cpp \
../src/graph/hooks/hooks.cpp \
../src/graph/hooks/input.cpp \
../src/graph/hooks/output.cpp \
Expand All @@ -21,6 +22,7 @@ HEADERS += \
../src/graph/datum/link.h \
../src/graph/node/serializer.h \
../src/graph/node/deserializer.h \
../src/graph/node/deserializer_old.h \
../src/graph/hooks/hooks.h \
../src/graph/hooks/input.h \
../src/graph/hooks/output.h \
Expand Down
44 changes: 34 additions & 10 deletions src/app/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "graph/datum/link.h"
#include "graph/node/serializer.h"
#include "graph/node/deserializer.h"
#include "graph/node/deserializer_old.h"

#include "fab/types/shape.h"

Expand Down Expand Up @@ -143,8 +144,7 @@ void App::onSave()
SceneSerializer ss(root,
graph_scene->inspectorPositions());

QDataStream out(&file);
ss.run(&out);
file.write(QJsonDocument(ss.run()).toJson());

stack->setClean();
}
Expand Down Expand Up @@ -200,16 +200,30 @@ void App::loadFile(QString f)
return;
}

QDataStream in(&file);
SceneDeserializer ds(root);
ds.run(&in);
ds.run(QJsonDocument::fromJson(file.readAll()).object());

if (ds.failed == true)
{
QMessageBox::critical(NULL, "Loading error",
"<b>Loading error:</b><br>" +
ds.error_message);
onNew();
// Attempt to load the file with the old deserializer
file.reset();
QDataStream in(&file);
SceneDeserializerOld dso(root);
dso.run(&in);

if (dso.failed)
{
QMessageBox::critical(NULL, "Loading error",
"<b>Loading error:</b><br>" +
dso.error_message);
onNew();
}
else
{
makeUI(root);
graph_scene->setInspectorPositions(dso.inspectors);
emit(windowTitleChanged(getWindowTitle()));
}
} else {
// If there's a warning message, show it in a box.
if (!ds.warning_message.isNull())
Expand Down Expand Up @@ -639,6 +653,7 @@ void App::newNode(Node* n)

void App::makeUI(NodeRoot* r)
{
QList<Node*> nodes;
QList<Datum*> datums;
QMap<Datum*, QList<Link*>> links;

Expand All @@ -659,7 +674,8 @@ void App::makeUI(NodeRoot* r)
k->setParent(NULL);
}
}
newNode(n);
graph_scene->makeUIfor(n);
nodes.append(n);
}

for (auto i = links.begin(); i != links.end(); ++i)
Expand All @@ -675,7 +691,15 @@ void App::makeUI(NodeRoot* r)
// Now that all links are created and all nodes are under the same
// root (in case of address-by-name), run update on every datum.
for (auto d : datums)
d->update();
if (!d->getValid())
d->update();

// Finally, make render workers for all of the new nodes.
// This needs to happen after connections are made; otherwise
// we end up with a ton of RenderWorkers that all start rendering
// at once (and eat up all of the threads).
for (auto n : nodes)
view_scene->makeRenderWorkersFor(n);
}

Connection* App::newLink(Link* link)
Expand Down
3 changes: 2 additions & 1 deletion src/app/undo/undo_delete_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <QList>
#include <QMap>
#include <QJsonObject>

#include "app/undo/undo_command.h"

Expand All @@ -28,7 +29,7 @@ class UndoDeleteNodeCommand : public UndoCommand
QList<Node*> nodes;
QMap<QString, Datum*> datums;

QByteArray data;
QJsonObject data;
};

#endif
49 changes: 28 additions & 21 deletions src/fab/tree/math/math_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,56 @@

#include "tree/math/math_r.h"

float* add_r(float* A, float* B, float* R, int c)
float* add_r(const float* restrict A, const float* restrict B,
float* restrict R, int c)
{
for (int q = 0; q < c; ++q)
R[q] = A[q] + B[q];
return R;
}

float* sub_r(float* A, float* B, float* R, int c)
float* sub_r(const float* restrict A, const float* restrict B,
float* restrict R, int c)
{
for (int q = 0; q < c; ++q)
R[q] = A[q] - B[q];
return R;
}

float* mul_r(float* A, float* B, float* R, int c)
float* mul_r(const float* restrict A, const float* restrict B,
float* R, int c)
{
for (int q = 0; q < c; ++q)
R[q] = A[q] * B[q];
return R;
}

float* div_r(float* A, float* B, float* R, int c)
float* div_r(const float* restrict A, const float* restrict B,
float* R, int c)
{
for (int q = 0; q < c; ++q)
R[q] = A[q] / B[q];
return R;
}

float* min_r(float* A, float* B, float* R, int c)
float* min_r(const float* restrict A, const float* restrict B,
float* R, int c)
{
for (int q = 0; q < c; ++q)
R[q] = fmin(A[q], B[q]);
return R;
}

float* max_r(float* A, float* B, float* R, int c)
float* max_r(const float* restrict A, const float* restrict B,
float* R, int c)
{
for (int q = 0; q < c; ++q)
R[q] = fmax(A[q], B[q]);
return R;
}

float* pow_r(float* A, float* B, float* R, int c)
float* pow_r(const float* restrict A, const float* restrict B,
float* R, int c)
{
for (int q = 0; q < c; ++q)
R[q] = pow(A[q], B[q]);
Expand All @@ -54,57 +61,57 @@ float* pow_r(float* A, float* B, float* R, int c)

////////////////////////////////////////////////////////////////////////////////

float* abs_r(float* A, float* R, int c)
float* abs_r(const float* restrict A, float* R, int c)
{
for (int q=0; q < c; ++q)
R[q] = fabs(A[q]);
return R;
}

float* square_r(float* A, float* R, int c)
float* square_r(const float* restrict A, float* R, int c)
{
for (int q = 0; q < c; ++q)
R[q] = A[q]*A[q];
return R;
}

float* sqrt_r(float* A, float* R, int c)
float* sqrt_r(const float* restrict A, float* R, int c)
{
for (int q = 0; q < c; ++q)
if (A[q] < 0) R[q] = 0;
else R[q] = sqrt(A[q]);
return R;
}

float* sin_r(float* A, float* R, int c)
float* sin_r(const float* restrict A, float* R, int c)
{
for (int q = 0; q < c; ++q)
R[q] = sin(A[q]);
return R;
}

float* cos_r(float* A, float* R, int c)
float* cos_r(const float* restrict A, float* R, int c)
{
for (int q = 0; q < c; ++q)
R[q] = cos(A[q]);
return R;
}

float* tan_r(float* A, float* R, int c)
float* tan_r(const float* restrict A, float* R, int c)
{
for (int q = 0; q < c; ++q)
R[q] = tan(A[q]);
return R;
}

float* asin_r(float* A, float* R, int c)
float* asin_r(const float* restrict A, float* R, int c)
{
for (int q = 0; q < c; ++q)
R[q] = asin(A[q]);
return R;
}

float* acos_r(float* A, float* R, int c)
float* acos_r(const float* restrict A, float* R, int c)
{
for (int q = 0; q < c; ++q) {
if (A[q] < -1) R[q] = M_PI;
Expand All @@ -114,21 +121,21 @@ float* acos_r(float* A, float* R, int c)
return R;
}

float* atan_r(float* A, float* R, int c)
float* atan_r(const float* restrict A, float* R, int c)
{
for (int q = 0; q < c; ++q)
R[q] = atan(A[q]);
return R;
}

float* neg_r(float* A, float* R, int c)
float* neg_r(const float* restrict A, float* R, int c)
{
for (int q = 0; q < c; ++q)
R[q] = -A[q];
return R;
}

float* exp_r(float* A, float* R, int c)
float* exp_r(const float* restrict A, float* R, int c)
{
for (int q = 0; q < c; ++q)
R[q] = exp(A[q]);
Expand All @@ -137,19 +144,19 @@ float* exp_r(float* A, float* R, int c)

////////////////////////////////////////////////////////////////////////////////

float* X_r(float* X, float* R, int c)
float* X_r(const float* restrict X, float* R, int c)
{
memcpy(R, X,c*sizeof(float));
return R;
}

float* Y_r(float* Y, float* R, int c)
float* Y_r(const float* restrict Y, float* R, int c)
{
memcpy(R, Y, c*sizeof(float));
return R;
}

float* Z_r(float* Z, float* R, int c)
float* Z_r(const float* restrict Z, float* R, int c)
{
memcpy(R, Z, c*sizeof(float));
return R;
Expand Down
Loading

0 comments on commit 9b883bf

Please sign in to comment.