mirror of https://github.com/odrling/Aegisub
Make Vector2D's default constructor initialize to the invalid value rather than a seemingly valid value. Fixes a few cases where uninitialized vectors were used as if they were initialized.
Originally committed to SVN as r5987.
This commit is contained in:
parent
f48c2a444d
commit
c0cfe8afce
|
@ -98,7 +98,7 @@ void Spline::DecodeFromASS(wxString str) {
|
||||||
|
|
||||||
// Prepare
|
// Prepare
|
||||||
char command = 'm';
|
char command = 'm';
|
||||||
Vector2D pt;
|
Vector2D pt(0, 0);
|
||||||
|
|
||||||
// Tokenize the string
|
// Tokenize the string
|
||||||
wxStringTokenizer tkn(str, " ");
|
wxStringTokenizer tkn(str, " ");
|
||||||
|
|
|
@ -62,7 +62,7 @@ public:
|
||||||
/// DOCME
|
/// DOCME
|
||||||
CurveType type;
|
CurveType type;
|
||||||
|
|
||||||
SplineCurve(Vector2D p1 = Vector2D());
|
SplineCurve(Vector2D p1 = Vector2D(0, 0));
|
||||||
SplineCurve(Vector2D p1, Vector2D p2);
|
SplineCurve(Vector2D p1, Vector2D p2);
|
||||||
SplineCurve(Vector2D p1, Vector2D p2, Vector2D p3, Vector2D p4);
|
SplineCurve(Vector2D p1, Vector2D p2, Vector2D p3, Vector2D p4);
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,12 @@
|
||||||
#include <wx/numformatter.h>
|
#include <wx/numformatter.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Vector2D::Vector2D()
|
||||||
|
: x(std::numeric_limits<float>::min())
|
||||||
|
, y(std::numeric_limits<float>::min())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Vector2D operator *(float f, Vector2D v) {
|
Vector2D operator *(float f, Vector2D v) {
|
||||||
return Vector2D(v.X() * f, v.Y() * f);
|
return Vector2D(v.X() * f, v.Y() * f);
|
||||||
}
|
}
|
||||||
|
@ -74,11 +80,7 @@ Vector2D Vector2D::Round(float step) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2D::operator unspecified_bool_type() const {
|
Vector2D::operator unspecified_bool_type() const {
|
||||||
return *this == Bad() ? 0 : &Vector2D::x;
|
return *this == Vector2D() ? 0 : &Vector2D::x;
|
||||||
}
|
|
||||||
|
|
||||||
Vector2D Vector2D::Bad() {
|
|
||||||
return Vector2D(std::numeric_limits<float>::min(), std::numeric_limits<float>::min());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString Vector2D::PStr(char sep) const {
|
wxString Vector2D::PStr(char sep) const {
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
float X() const { return x; }
|
float X() const { return x; }
|
||||||
float Y() const { return y; }
|
float Y() const { return y; }
|
||||||
|
|
||||||
Vector2D() : x(0), y(0) { }
|
Vector2D();
|
||||||
Vector2D(float x, float y) : x(x), y(y) { }
|
Vector2D(float x, float y) : x(x), y(y) { }
|
||||||
Vector2D(wxPoint pt) : x(pt.x), y(pt.y) { }
|
Vector2D(wxPoint pt) : x(pt.x), y(pt.y) { }
|
||||||
Vector2D(Vector2D x, Vector2D y) : x(x.x), y(y.y) { }
|
Vector2D(Vector2D x, Vector2D y) : x(x.x), y(y.y) { }
|
||||||
|
@ -87,7 +87,6 @@ public:
|
||||||
wxString DStr(char sep = ',') const;
|
wxString DStr(char sep = ',') const;
|
||||||
|
|
||||||
static Vector2D FromAngle(float angle) { return Vector2D(cos(-angle), sin(-angle)); }
|
static Vector2D FromAngle(float angle) { return Vector2D(cos(-angle), sin(-angle)); }
|
||||||
static Vector2D Bad();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Vector2D operator * (float f, Vector2D v);
|
Vector2D operator * (float f, Vector2D v);
|
||||||
|
|
|
@ -98,7 +98,6 @@ VideoDisplay::VideoDisplay(
|
||||||
, con(c)
|
, con(c)
|
||||||
, w(8)
|
, w(8)
|
||||||
, h(8)
|
, h(8)
|
||||||
, mouse_pos(Vector2D::Bad())
|
|
||||||
, viewport_left(0)
|
, viewport_left(0)
|
||||||
, viewport_width(0)
|
, viewport_width(0)
|
||||||
, viewport_bottom(0)
|
, viewport_bottom(0)
|
||||||
|
@ -353,7 +352,7 @@ void VideoDisplay::OnMouseEvent(wxMouseEvent& event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoDisplay::OnMouseLeave(wxMouseEvent& event) {
|
void VideoDisplay::OnMouseLeave(wxMouseEvent& event) {
|
||||||
mouse_pos = Vector2D::Bad();
|
mouse_pos = Vector2D();
|
||||||
tool->OnMouseEvent(event);
|
tool->OnMouseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,9 +40,7 @@
|
||||||
#include "visual_feature.h"
|
#include "visual_feature.h"
|
||||||
|
|
||||||
VisualDraggableFeature::VisualDraggableFeature()
|
VisualDraggableFeature::VisualDraggableFeature()
|
||||||
: start(Vector2D::Bad())
|
: type(DRAG_NONE)
|
||||||
, type(DRAG_NONE)
|
|
||||||
, pos(Vector2D::Bad())
|
|
||||||
, layer(0)
|
, layer(0)
|
||||||
, line(0)
|
, line(0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -192,7 +192,7 @@ void VisualTool<FeatureType>::OnMouseEvent(wxMouseEvent &event) {
|
||||||
bool need_render = false;
|
bool need_render = false;
|
||||||
|
|
||||||
if (event.Leaving()) {
|
if (event.Leaving()) {
|
||||||
mouse_pos = Vector2D::Bad();
|
mouse_pos = Vector2D();
|
||||||
parent->Render();
|
parent->Render();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -392,7 +392,7 @@ static Vector2D vec_or_bad(param_vec tag, size_t x_idx, size_t y_idx) {
|
||||||
(*tag)[x_idx]->omitted || (*tag)[y_idx]->omitted ||
|
(*tag)[x_idx]->omitted || (*tag)[y_idx]->omitted ||
|
||||||
(*tag)[x_idx]->GetType() == VARDATA_NONE || (*tag)[y_idx]->GetType() == VARDATA_NONE)
|
(*tag)[x_idx]->GetType() == VARDATA_NONE || (*tag)[y_idx]->GetType() == VARDATA_NONE)
|
||||||
{
|
{
|
||||||
return Vector2D::Bad();
|
return Vector2D();
|
||||||
}
|
}
|
||||||
return Vector2D((*tag)[x_idx]->Get<float>(), (*tag)[y_idx]->Get<float>());
|
return Vector2D((*tag)[x_idx]->Get<float>(), (*tag)[y_idx]->Get<float>());
|
||||||
}
|
}
|
||||||
|
@ -525,7 +525,7 @@ void VisualToolBase::GetLineClip(AssDialogue *diag, Vector2D &p1, Vector2D &p2,
|
||||||
p2 = vec_or_bad(tag, 2, 3);
|
p2 = vec_or_bad(tag, 2, 3);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p1 = Vector2D();
|
p1 = Vector2D(0, 0);
|
||||||
p2 = script_res - 1;
|
p2 = script_res - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ void VisualToolRotateZ::Draw() {
|
||||||
// Draw the circle
|
// Draw the circle
|
||||||
gl.SetLineColour(colour[0]);
|
gl.SetLineColour(colour[0]);
|
||||||
gl.SetFillColour(colour[1], 0.3f);
|
gl.SetFillColour(colour[1], 0.3f);
|
||||||
gl.DrawRing(Vector2D(), radius + 4, radius - 4);
|
gl.DrawRing(Vector2D(0, 0), radius + 4, radius - 4);
|
||||||
|
|
||||||
// Draw markers around circle
|
// Draw markers around circle
|
||||||
int markers = 6;
|
int markers = 6;
|
||||||
|
@ -67,7 +67,7 @@ void VisualToolRotateZ::Draw() {
|
||||||
float markEnd = markStart + (180.f / markers);
|
float markEnd = markStart + (180.f / markers);
|
||||||
for (int i = 0; i < markers; ++i) {
|
for (int i = 0; i < markers; ++i) {
|
||||||
float angle = i * (360.f / markers);
|
float angle = i * (360.f / markers);
|
||||||
gl.DrawRing(Vector2D(), radius+30, radius+12, 1.0, angle+markStart, angle+markEnd);
|
gl.DrawRing(Vector2D(0, 0), radius+30, radius+12, 1.0, angle+markStart, angle+markEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the baseline through the origin showing current rotation
|
// Draw the baseline through the origin showing current rotation
|
||||||
|
|
|
@ -100,7 +100,7 @@ void VisualToolScale::UpdateHold() {
|
||||||
if (shift_down)
|
if (shift_down)
|
||||||
delta = delta.SingleAxis();
|
delta = delta.SingleAxis();
|
||||||
|
|
||||||
scale = Vector2D().Max(delta * 1.25f + initial_scale);
|
scale = Vector2D(0, 0).Max(delta * 1.25f + initial_scale);
|
||||||
if (ctrl_down)
|
if (ctrl_down)
|
||||||
scale = scale.Round(25.f);
|
scale = scale.Round(25.f);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue