Skip to content

Commit

Permalink
made the lib betterC compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeMyst committed Jun 28, 2020
1 parent 9e78769 commit 03fc9c4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
12 changes: 3 additions & 9 deletions source/cosmomyst/math/matrix.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ struct mat(ulong n) if (n >= 2) {
}

@nogc this(T...)(T args) pure nothrow {
import std.traits : isNumeric;

static foreach (arg; args) {
static assert(is(typeof(arg) == float) || is(typeof(arg) == const(float)), "all values must be of type float");
static assert(isNumeric!(typeof(arg)), "all values must be numeric");
}

static assert(args.length > 0, "no args provided");
Expand Down Expand Up @@ -132,11 +134,6 @@ struct mat(ulong n) if (n >= 2) {
return res;
}

string toString() {
import std.format : format;
return format!("%s")(c);
}

/++
+ internal data as a pointer, use for sending data to shaders.
+/
Expand Down Expand Up @@ -343,8 +340,6 @@ unittest {

t1[0, 0] = 5f;
assert(t1[0, 0] == 5f);

assert(t1.toString() == "[[5, 2], [2, 2]]");
}

unittest {
Expand Down Expand Up @@ -400,7 +395,6 @@ unittest {
}

unittest {

auto m1 = mat4(5f, 6f, 6f, 8f, 2f, 2f, 2f, 8f, 6f, 6f, 2f, 8f, 2f, 3f, 6f, 7f);
assert(mat_inverse(m1) * m1 == mat_ident!4());
}
10 changes: 1 addition & 9 deletions source/cosmomyst/math/vector.d
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ struct vec(ulong n) if (n >= 1) {
return this / length();
}

string toString() const {
import std.string : format;
return format("%s", v);
}

/++
+ returns the negated vector.
+/
Expand Down Expand Up @@ -221,10 +216,9 @@ struct vec(ulong n) if (n >= 1) {
+ returns the dot product of 2 vectors.
+/
@nogc float vec_dot(ulong n)(vec!n a, vec!n b) pure nothrow {
import std.format : format;
float res = 0f;
static foreach (i; 0..n) {
mixin(format!("res += a.v[%s] * b.v[%s];")(i, i));
res += a.v[i] * b.v[i];
}
return res;
}
Expand All @@ -247,8 +241,6 @@ unittest {
auto t2 = vec2(2f);
assert(t2.x == 2f);
assert(t2.y == 2f);

assert(t1.toString() == "[2, 3]");
}

unittest {
Expand Down

0 comments on commit 03fc9c4

Please sign in to comment.