SFML community forums
General => General discussions => Topic started by: OniLinkPlus on June 06, 2010, 11:55:19 pm
-
Alright, so since Laurent seems to be busy, I decided to use my amazingly large amount of free time to fix whatever bugs in the tasklist that I can. The first bug I tried to fix was #160. Lines 450 to 454 in WindowImplWin32.cpp were changed to this:
// Resize event
case WM_SIZE :
{
// Update window size
RECT rectangle;
GetClientRect(myHandle, &rectangle);
myWidth = rectangle.right - rectangle.left;
myHeight = rectangle.bottom - rectangle.top;
if (myWidth != 0 && myHeight != 0){
Event event;
event.Type = Event::Resized;
event.Size.Width = myWidth;
event.Size.Height = myHeight;
PushEvent(event);
}
break;
}
I would assume this would fix the bug. I will be going through the tasklist and fix whatever bugs I can.
-
Added Length() and Normalize() to sf::Vector2<T>. The code in the header is before the member data and is
////////////////////////////////////////////////////////////
/// \brief Get the length of the vector
///
/// \return The length of the vector
////////////////////////////////////////////////////////////
T Length();
////////////////////////////////////////////////////////////
/// \brief Normalize the length of the vector to 1
////////////////////////////////////////////////////////////
void Normalize();
The code in the inline include is just after the constructors and is
////////////////////////////////////////////////////////////
template <typename T>
inline T Vector2<T>::Length()
{
return sqrt(x*x+y*y);
}
////////////////////////////////////////////////////////////
template <typename T>
inline void Vector2<T>::Normalize()
{
x /= Length();
y /= Length();
}
Going to add these to Vector3 next, and probably going to add Dot and Cross Products. The question is, how should I implement to Dot and Cross Products? As a global function or an inline static member function?
-
Added the Length and Normalize functions to Vector3 with these lines in header
////////////////////////////////////////////////////////////
/// \brief Get the length of the vector
///
/// \return The length of the vector
////////////////////////////////////////////////////////////
T Length();
////////////////////////////////////////////////////////////
/// \brief Normalize the length of the vector to 1
////////////////////////////////////////////////////////////
void Normalize();
and these lines in the inline file
////////////////////////////////////////////////////////////
template <typename T>
inline T Vector3<T>::Length(){
return sqrt(x*x+y*y+z*z);
}
////////////////////////////////////////////////////////////
template <typename T>
inline void Vector3<T>::Normalize(){
x /= Length();
y /= Length();
z /= Length();
}
-
Hi
Thank you very much, but things are not going to be faster than if I did it myself. As you can see, it's just a few lines of code and it will take me the same amount of time to apply your patches.
I know that it may sound rude, especially for an open-source project, but I prefer doing things myself. The main reason is that I want to think about every single task to make sure that I'm not missing anything. For example, your first patch is the wrong way to go. The code must test lParam (there is a special value for the minimize event), so that we don't ignore other potential valid situations where the size can really be zero. I also have to test this behaviour on Linux, and write a patch if the same thing happens.
Something else: you're not following my coding rules, so I'd have to review your code and adjust it (ok, this is not really a big deal here, but imagine a patch of hundreds of lines).
Regarding the vector functions, I'm still thinking about what to add and how to add it. It's really not that I don't have the time or the skills to add these 4 lines of code :)
But thanks for your help, I really appreciate and I feel a little guilty to give you this answer.