Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: NetEXT - SFML.NET Extension Library based on Thor  (Read 42377 times)

0 Members and 2 Guests are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #30 on: April 18, 2014, 11:17:04 pm »
Quote
if (Math.Abs(mag) > Math.Abs(0) || (vec.X != 0 && vec.Y != 0))
What's the purpose of this double-check? How could X and Y be both non-zero if the length of the vector is zero? And do you really expect Math.Abs(0) to do something useful? :P

public static Vector2f normalizedVector2(Vector2f vec)
{
    float mag = VectorMagnitude(vec);
    return  mag != 0 ? vec / mag : vec;
}

Quote
I added assertions so now invalid vectors in debug configuration will throw an error
I think returning the zero vector in this case would be more natural than throwing an error. A vector with zero length is valid, it's just a special case to handle.
« Last Edit: April 18, 2014, 11:18:47 pm by Laurent »
Laurent Gomila - SFML developer

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #31 on: April 18, 2014, 11:26:48 pm »
I think returning the zero vector in this case would be more natural than throwing an error. A vector with zero length is valid, it's just a special case to handle.

Hmmm, I would like to know what Nexus thinks of this. I am open to change, but when I implemented the assertions I was following Thor's implementation. Personally I haven't done enough math dealing with vectors to know the best way to handle this.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #32 on: April 19, 2014, 12:02:13 am »
I think returning the zero vector in this case would be more natural than throwing an error. A vector with zero length is valid, it's just a special case to handle.
My point of view here is that UnitVector() claims to return a vector of unit length. If it doesn't, that's a violation of the method's postcondition. Analoguously, a vector of length zero is not a valid input -- you cannot compute the unit vector of a zero vector. Same thing if you compute the polar angle. In otherwords, the precondition is a non-zero vector argument, and Thor explicitly states that in the documentation.

I'm personally not a fan of hiding logic errors like this; if the user wants to handle zero vectors differently, he should do so explicitly. The nice side effect is that users who really want to compute a unit vector don't pay for a useless if statement.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #33 on: April 19, 2014, 01:08:42 am »
Quote
if (Math.Abs(mag) > Math.Abs(0) || (vec.X != 0 && vec.Y != 0))
What's the purpose of this double-check? How could X and Y be both non-zero if the length of the vector is zero? And do you really expect Math.Abs(0) to do something useful? :P


lol Brain fart on my end.  For some reason went for double check when I didn't have to. XD


I think returning the zero vector in this case would be more natural than throwing an error. A vector with zero length is valid, it's just a special case to handle.
My point of view here is that UnitVector() claims to return a vector of unit length. If it doesn't, that's a violation of the method's postcondition. Analoguously, a vector of length zero is not a valid input -- you cannot compute the unit vector of a zero vector. Same thing if you compute the polar angle. In otherwords, the precondition is a non-zero vector argument, and Thor explicitly states that in the documentation.

I'm personally not a fan of hiding logic errors like this; if the user wants to handle zero vectors differently, he should do so explicitly. The nice side effect is that users who really want to compute a unit vector don't pay for a useless if statement.

Sometimes throwing an error is good other times like when doing AI calculations it can be annoying so I went for just returning the passed vector without doing anything to it since it won't crash me when I don't want it to. :) Although yes I'm not much of a fan of hiding errors like this either when they shouldn't be hidden. :D
I have many ideas but need the help of others to find way to make use of them.

AbelToy

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • AbelToy.com
    • Email
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #34 on: May 28, 2014, 12:52:21 pm »
If I use string as the Key for a TextureCache, it randomly gets freed? How can I use resources properly?

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #35 on: May 29, 2014, 03:57:57 am »
If I use string as the Key for a TextureCache, it randomly gets freed?

What do you mean by randomly freed? If you think there is an issue I need a complete and minimal code example to test with.

Quote
How can I use resources properly?

There is an example in the source code for you to look at.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

eyeliner

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #36 on: July 23, 2014, 12:16:26 am »
Hey there. Thank for this, but I can't build it.
It rants about this:
Quote
Error   1   The type or namespace name 'System' does not exist in the namespace 'SFML' (are you missing an assembly reference?)   D:\GameMaking\NetEXT\NetEXT\TimeFunctions\Stopwatch.cs   2   12   NetEXT

With loads of errors like this.

And these warnings:
Quote
Warning   49   'NetEXT.Particles.ParticleSystem.ExpiringTime' overrides Object.Equals(object o) but does not override Object.GetHashCode()   D:\GameMaking\NetEXT\NetEXT\Particles\ParticleSystem.cs   281   23   NetEXT
Warning   55   'NetEXT.Particles.ParticleSystem.TimeLink<TimeType,ValueType>' overrides Object.Equals(object o) but does not override Object.GetHashCode()   D:\GameMaking\NetEXT\NetEXT\Particles\ParticleSystem.cs   328   23   NetEXT


I want to build a 64bit version, because I downloaded the .dll present and apparently it is not 64bit.

Am I being dense, or some compatibility somewhere lurks in my vicinity?

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #37 on: July 23, 2014, 03:03:24 am »
NetEXT has been updated to work with the latest SFML.NET version (the soon to be released 2.2 version). So you will need to download and compile the latest SFML.NET and grab the latest nightly builds of CSFML from here (or compile it yourself). As for the warnings, you can safely ignore them.
« Last Edit: July 23, 2014, 03:07:05 am by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #38 on: December 19, 2014, 12:40:42 am »
Hello, was just wondering if this even needed to be updated from the 2.2 release? :)
I have many ideas but need the help of others to find way to make use of them.

DurtyFree

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #39 on: May 14, 2016, 08:02:59 pm »
Is this library still in active development?