Trass3r wrote:
I also wanted to allow for swizzled setters, but apparently that's
currently not possible[1].
[1]: http://d.puremagic.com/issues/show_bug.cgi?id=620
What a pity!
Actually, after a bit of hacking, I have found a way:
// new helper function
static private bool noCharsRepeate
I can't help but wonder if those neat SSE functions are a waste.
Functions that use inline assembly cannot be inlined, and thus aren't
necessarily faster than using good old x87. Now, if only DMD had some
intrinsics for that...
Who knows.
At least it was a nice exercise in writing SSE :)
Am 01.10.2010, 13:47 Uhr, schrieb Simen kjaeraas :
Oh, and also (if you don't mind my nitpicking), have you profiled
invSqrt compared to 1/sqrt? Last time I did, I found that invSqrt
was about 50% slower than 1/sqrt.
Haven't profiled it yet.
The one thing I missed when looking at the code w
> What would swizzled setters look like?
>
> vec.yx = vec.xy ?
Yes.
> vec.xy = [1,0] ?
Maybe. Or like
vec.xy = Vector!2(1,0);
> vec.xxx = [0,1,2];
No. To be an lvalue the swizzling must not contain duplicate components.
For more information see p65 in the GLSL Spec.
http://www.opengl.org/r
On Fri, Oct 1, 2010 at 08:35, Sebastian Schuberth wrote:
> You're right, I want exactly N T's, but from reading the section about
> "Typesafe Variadic Functions" at [1], I thought I'm doing exactly that. The
> example "For static arrays" has a comment which says for a declaration like
(...)
> wou
On Fri, Oct 1, 2010 at 13:47, Simen kjaeraas wrote:
> I also wanted to allow for swizzled setters, but apparently that's
> currently not possible
What would swizzled setters look like?
vec.yx = vec.xy ?
vec.xy = [1,0] ?
What about
vec.xxx = [0,1,2];
Would Vec.x be 2 after this?
Philippe
Sebastian Schuberth:
> With tuples, would it still be that sizeof(Vector)==sizeof(T)*N?
Yes, I think it would (if the types of the tuple are all equal I think there is
no padding), a TypeTuple doen't exist at runtime, only its parts exist. In
similar situations you save time asking to the compi
Simen kjaeraas wrote:
Trass3r wrote:
Here's a basic D2 fixed-size vector implementation for you to study:
http://sfml.svn.sourceforge.net/viewvc/sfml/branches/sfml2/DSFML/import/dsfml/system/vector.d?view=markup
I can't help but wonder if those neat SSE functions are a waste.
Functions th
Trass3r wrote:
Here's a basic D2 fixed-size vector implementation for you to study:
http://sfml.svn.sourceforge.net/viewvc/sfml/branches/sfml2/DSFML/import/dsfml/system/vector.d?view=markup
I can't help but wonder if those neat SSE functions are a waste.
Functions that use inline assembly ca
Sebastian Schuberth wrote:
As a side note, I find the syntax quite unfortunate. It reads to me as
if the static constructor will only be called if the default constructor
is used (I know, this does not make sense as the static constructor will
be called before main, and before any non-stat
On 30.09.2010 22:04, Jonathan M Davis wrote:
You could initialized it in a static constructor. e.g.
static this()
{
X = Vector(1, 0, 0);
}
I'll use that, thanks.
As a side note, I find the syntax quite unfortunate. It reads to me as
if the static constructor will only be called if t
On 30.09.2010 23:10, Trass3r wrote:
Here's a basic D2 fixed-size vector implementation for you to study:
http://sfml.svn.sourceforge.net/viewvc/sfml/branches/sfml2/DSFML/import/dsfml/system/vector.d?view=markup
Thanks a lot, I was already looking for an example like that!
--
Sebastian Schuber
On 30.09.2010 22:01, Philippe Sigaud wrote:
To me, your constructor's signature is saying: "give me any number of
T[N]", which I guess is not what you want. You want exactly N T's.
You're right, I want exactly N T's, but from reading the section about
"Typesafe Variadic Functions" at [1], I t
Will it convert N T's into a T[N]?
Ah wait, yeah, he uses an array.
What I mentioned works only if you have a struct with members x, y, z, ...
On Thu, Sep 30, 2010 at 22:32, bearophile wrote:
> Philippe Sigaud:
>
>> It's doable, but it means modifying your struct a bit: instead of
>> holding the values in an array, you can store them in a tuple.
>> I'll see if anyone as another idea: I'm biased towards tuples.
>
> Please, be gentle with
On Thu, Sep 30, 2010 at 23:10, Trass3r wrote:
> This sort of constructor shouldn't be necessary since an implicit one will
> be generated.
Will it convert N T's into a T[N]?
I also tried simply
struct Vector(alias N,T)
{
static immutable Vector X=Vector(1,0,0);
this(T x,T y,T z) {
data[0]=x;
data[1]=y;
data[2]=z;
}
T data[N];
};
This sort of constructor shouldn't be necessary since an implicit one will
be generated
Philippe Sigaud:
> It's doable, but it means modifying your struct a bit: instead of
> holding the values in an array, you can store them in a tuple.
> I'll see if anyone as another idea: I'm biased towards tuples.
Please, be gentle with the D newbie, don't burn his brain :-) You can't learn a
b
Sebastian Schuberth:
> struct Vector(alias N,T)
> {
> static immutable Vector X=Vector(1,0,0);
>
> this(T[N] v ...) {
> data=v;
> }
>
> T data[N];
> };
>
> alias Vector!(3,float) Vec3f;
This seems to work:
struct Vector(int N, T) {
static immutable Vector x;
On Thursday 30 September 2010 12:14:09 Sebastian Schuberth wrote:
> Hi,
>
> I'm still playing around with DMD 2.049 and my Vector struct. This
>
> struct Vector(alias N,T)
> {
> static immutable Vector X=Vector(1,0,0);
>
> this(T[N] v ...) {
> data=v;
> }
>
> T data
On Thu, Sep 30, 2010 at 21:14, Sebastian Schuberth wrote:
> Hi,
>
> I'm still playing around with DMD 2.049 and my Vector struct. This
>
> struct Vector(alias N,T)
> {
> static immutable Vector X=Vector(1,0,0);
>
> this(T[N] v ...) {
> data=v;
> }
>
> T data[N];
> };
To me, you
Hi,
I'm still playing around with DMD 2.049 and my Vector struct. This
struct Vector(alias N,T)
{
static immutable Vector X=Vector(1,0,0);
this(T[N] v ...) {
data=v;
}
T data[N];
};
alias Vector!(3,float) Vec3f;
gives
Error 1 Error: Slice operation this.data[] = cast
22 matches
Mail list logo