1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Allow chaining the Generate() method.

This commit is contained in:
Sandu Liviu Catalin 2021-03-20 17:56:38 +02:00
parent 1ed005e571
commit d18719a6d8
18 changed files with 151 additions and 93 deletions

View File

@ -406,14 +406,16 @@ void Circle::SetStr(SQChar delim, StackStrF & values)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Circle::Generate() Circle & Circle::Generate()
{ {
pos.Generate(); pos.Generate();
rad = GetRandomFloat32(); rad = GetRandomFloat32();
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Circle::Generate(Value min, Value max, bool r) Circle & Circle::GenerateB(Value min, Value max, bool r)
{ {
if (EpsLt(max, min)) if (EpsLt(max, min))
{ {
@ -425,31 +427,37 @@ void Circle::Generate(Value min, Value max, bool r)
} }
else else
{ {
pos.Generate(min, max); pos.GenerateB(min, max);
} }
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Circle::Generate(Value xmin, Value xmax, Value ymin, Value ymax) Circle & Circle::GenerateR(Value xmin, Value xmax, Value ymin, Value ymax)
{ {
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin)) if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin))
{ {
STHROWF("max value is lower than min value"); STHROWF("max value is lower than min value");
} }
pos.Generate(xmin, xmax, ymin, ymax); pos.GenerateR(xmin, xmax, ymin, ymax);
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Circle::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value rmin, Value rmax) Circle & Circle::GenerateR2(Value xmin, Value xmax, Value ymin, Value ymax, Value rmin, Value rmax)
{ {
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(rmax, rmin)) if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(rmax, rmin))
{ {
STHROWF("max value is lower than min value"); STHROWF("max value is lower than min value");
} }
pos.Generate(xmin, xmax, ymin, ymax); pos.GenerateR(xmin, xmax, ymin, ymax);
rad = GetRandomFloat32(rmin, rmax); rad = GetRandomFloat32(rmin, rmax);
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -567,10 +575,10 @@ void Register_Circle(HSQUIRRELVM vm)
.FmtFunc(_SC("Format"), &Circle::Format) .FmtFunc(_SC("Format"), &Circle::Format)
.Func(_SC("ToPointsArray"), &Circle::ToPointsArray) .Func(_SC("ToPointsArray"), &Circle::ToPointsArray)
// Member Overloads // Member Overloads
.Overload< void (Circle::*)(void) >(_SC("Generate"), &Circle::Generate) .Overload(_SC("Generate"), &Circle::Generate)
.Overload< void (Circle::*)(Val, Val, bool) >(_SC("Generate"), &Circle::Generate) .Overload(_SC("Generate"), &Circle::GenerateB)
.Overload< void (Circle::*)(Val, Val, Val, Val) >(_SC("Generate"), &Circle::Generate) .Overload(_SC("Generate"), &Circle::GenerateR)
.Overload< void (Circle::*)(Val, Val, Val, Val, Val, Val) >(_SC("Generate"), &Circle::Generate) .Overload(_SC("Generate"), &Circle::GenerateR2)
// Static Functions // Static Functions
.StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Circle >) .StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Circle >)
.StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Circle >) .StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Circle >)

View File

@ -379,22 +379,22 @@ struct Circle
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate a randomly sized and positioned circle. * Generate a randomly sized and positioned circle.
*/ */
void Generate(); Circle & Generate();
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate a randomly sized or positioned circle within the specified bounds. * Generate a randomly sized or positioned circle within the specified bounds.
*/ */
void Generate(Value min, Value max, bool r); Circle & GenerateB(Value min, Value max, bool r);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate a randomly positioned circle within the specified bounds. * Generate a randomly positioned circle within the specified bounds.
*/ */
void Generate(Value xmin, Value xmax, Value ymin, Value ymax); Circle & GenerateR(Value xmin, Value xmax, Value ymin, Value ymax);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate a randomly sized and positioned circle within the specified bounds. * Generate a randomly sized and positioned circle within the specified bounds.
*/ */
void Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value rmin, Value rmax); Circle & GenerateR2(Value xmin, Value xmax, Value ymin, Value ymax, Value rmin, Value rmax);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Clear the component values to default. * Clear the component values to default.

View File

@ -576,15 +576,17 @@ void Color3::SetARGB(uint32_t p)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Color3::Generate() Color3 & Color3::Generate()
{ {
r = GetRandomUint8(); r = GetRandomUint8();
g = GetRandomUint8(); g = GetRandomUint8();
b = GetRandomUint8(); b = GetRandomUint8();
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Color3::Generate(Value min, Value max) Color3 & Color3::GenerateB(Value min, Value max)
{ {
if (max < min) if (max < min)
{ {
@ -594,10 +596,12 @@ void Color3::Generate(Value min, Value max)
r = GetRandomUint8(min, max); r = GetRandomUint8(min, max);
g = GetRandomUint8(min, max); g = GetRandomUint8(min, max);
b = GetRandomUint8(min, max); b = GetRandomUint8(min, max);
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Color3::Generate(Value rmin, Value rmax, Value gmin, Value gmax, Value bmin, Value bmax) Color3 & Color3::GenerateR(Value rmin, Value rmax, Value gmin, Value gmax, Value bmin, Value bmax)
{ {
if (rmax < rmin || gmax < gmin || bmax < bmin) if (rmax < rmin || gmax < gmin || bmax < bmin)
{ {
@ -607,6 +611,8 @@ void Color3::Generate(Value rmin, Value rmax, Value gmin, Value gmax, Value bmin
r = GetRandomUint8(rmin, rmax); r = GetRandomUint8(rmin, rmax);
g = GetRandomUint8(gmin, gmax); g = GetRandomUint8(gmin, gmax);
b = GetRandomUint8(bmin, bmax); b = GetRandomUint8(bmin, bmax);
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -761,9 +767,9 @@ void Register_Color3(HSQUIRRELVM vm)
.Func(_SC("Random"), &Color3::Random) .Func(_SC("Random"), &Color3::Random)
.Func(_SC("Inverse"), &Color3::Inverse) .Func(_SC("Inverse"), &Color3::Inverse)
// Member Overloads // Member Overloads
.Overload< void (Color3::*)(void) >(_SC("Generate"), &Color3::Generate) .Overload(_SC("Generate"), &Color3::Generate)
.Overload< void (Color3::*)(Val, Val) >(_SC("Generate"), &Color3::Generate) .Overload(_SC("Generate"), &Color3::GenerateB)
.Overload< void (Color3::*)(Val, Val, Val, Val, Val, Val) >(_SC("Generate"), &Color3::Generate) .Overload(_SC("Generate"), &Color3::GenerateR)
// Static Functions // Static Functions
.StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Color3 >) .StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Color3 >)
.StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Color3 >) .StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Color3 >)

View File

@ -473,17 +473,17 @@ struct Color3
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance. * Generate random values for all components of this instance.
*/ */
void Generate(); Color3 & Generate();
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance within the specified bounds. * Generate random values for all components of this instance within the specified bounds.
*/ */
void Generate(Value min, Value max); Color3 & GenerateB(Value min, Value max);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance within the specified bounds. * Generate random values for all components of this instance within the specified bounds.
*/ */
void Generate(Value rmin, Value rmax, Value gmin, Value gmax, Value bmin, Value bmax); Color3 & GenerateR(Value rmin, Value rmax, Value gmin, Value gmax, Value bmin, Value bmax);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Clear the component values to default. * Clear the component values to default.

View File

@ -607,16 +607,18 @@ void Color4::SetARGB(uint32_t p)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Color4::Generate() Color4 & Color4::Generate()
{ {
r = GetRandomUint8(); r = GetRandomUint8();
g = GetRandomUint8(); g = GetRandomUint8();
b = GetRandomUint8(); b = GetRandomUint8();
a = GetRandomUint8(); a = GetRandomUint8();
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Color4::Generate(Value min, Value max) Color4 & Color4::GenerateB(Value min, Value max)
{ {
if (max < min) if (max < min)
{ {
@ -627,10 +629,12 @@ void Color4::Generate(Value min, Value max)
g = GetRandomUint8(min, max); g = GetRandomUint8(min, max);
b = GetRandomUint8(min, max); b = GetRandomUint8(min, max);
a = GetRandomUint8(min, max); a = GetRandomUint8(min, max);
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Color4::Generate(Value rmin, Value rmax, Value gmin, Value gmax, Value bmin, Value bmax, Value amin, Value amax) Color4 & Color4::GenerateR(Value rmin, Value rmax, Value gmin, Value gmax, Value bmin, Value bmax, Value amin, Value amax)
{ {
if (rmax < rmin || gmax < gmin || bmax < bmin || amax < amin) if (rmax < rmin || gmax < gmin || bmax < bmin || amax < amin)
{ {
@ -641,6 +645,8 @@ void Color4::Generate(Value rmin, Value rmax, Value gmin, Value gmax, Value bmin
g = GetRandomUint8(gmin, gmax); g = GetRandomUint8(gmin, gmax);
b = GetRandomUint8(bmin, bmax); b = GetRandomUint8(bmin, bmax);
a = GetRandomUint8(bmin, bmax); a = GetRandomUint8(bmin, bmax);
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -801,9 +807,9 @@ void Register_Color4(HSQUIRRELVM vm)
.Func(_SC("Random"), &Color4::Random) .Func(_SC("Random"), &Color4::Random)
.Func(_SC("Inverse"), &Color4::Inverse) .Func(_SC("Inverse"), &Color4::Inverse)
// Member Overloads // Member Overloads
.Overload< void (Color4::*)(void) >(_SC("Generate"), &Color4::Generate) .Overload(_SC("Generate"), &Color4::Generate)
.Overload< void (Color4::*)(Val, Val) >(_SC("Generate"), &Color4::Generate) .Overload(_SC("Generate"), &Color4::GenerateB)
.Overload< void (Color4::*)(Val, Val, Val, Val, Val, Val, Val, Val) >(_SC("Generate"), &Color4::Generate) .Overload(_SC("Generate"), &Color4::GenerateR)
// Static Functions // Static Functions
.StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Color4 >) .StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Color4 >)
.StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Color4 >) .StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Color4 >)

View File

@ -473,17 +473,17 @@ struct Color4
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance. * Generate random values for all components of this instance.
*/ */
void Generate(); Color4 & Generate();
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance within the specified bounds. * Generate random values for all components of this instance within the specified bounds.
*/ */
void Generate(Value min, Value max); Color4 & GenerateB(Value min, Value max);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance within the specified bounds. * Generate random values for all components of this instance within the specified bounds.
*/ */
void Generate(Value rmin, Value rmax, Value gmin, Value gmax, Value bmin, Value bmax, Value amin, Value amax); Color4 & GenerateR(Value rmin, Value rmax, Value gmin, Value gmax, Value bmin, Value bmax, Value amin, Value amax);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Clear the component values to default. * Clear the component values to default.

View File

@ -428,16 +428,18 @@ void Quaternion::SetStr(SQChar delim, StackStrF & values)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Quaternion::Generate() Quaternion & Quaternion::Generate()
{ {
x = GetRandomFloat32(); x = GetRandomFloat32();
y = GetRandomFloat32(); y = GetRandomFloat32();
z = GetRandomFloat32(); z = GetRandomFloat32();
w = GetRandomFloat32(); w = GetRandomFloat32();
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Quaternion::Generate(Value min, Value max) Quaternion & Quaternion::GenerateB(Value min, Value max)
{ {
if (EpsLt(max, min)) if (EpsLt(max, min))
{ {
@ -448,10 +450,12 @@ void Quaternion::Generate(Value min, Value max)
y = GetRandomFloat32(min, max); y = GetRandomFloat32(min, max);
z = GetRandomFloat32(min, max); z = GetRandomFloat32(min, max);
y = GetRandomFloat32(min, max); y = GetRandomFloat32(min, max);
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Quaternion::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value wmin, Value wmax) Quaternion & Quaternion::GenerateR(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value wmin, Value wmax)
{ {
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(zmax, zmin) || EpsLt(wmax, wmin)) if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(zmax, zmin) || EpsLt(wmax, wmin))
{ {
@ -462,6 +466,8 @@ void Quaternion::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value
y = GetRandomFloat32(ymin, ymax); y = GetRandomFloat32(ymin, ymax);
z = GetRandomFloat32(zmin, zmax); z = GetRandomFloat32(zmin, zmax);
y = GetRandomFloat32(ymin, ymax); y = GetRandomFloat32(ymin, ymax);
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -805,9 +811,9 @@ void Register_Quaternion(HSQUIRRELVM vm)
.Func(_SC("Nlerp"), &Quaternion::Nlerp) .Func(_SC("Nlerp"), &Quaternion::Nlerp)
.Func(_SC("NlerpEx"), &Quaternion::NlerpEx) .Func(_SC("NlerpEx"), &Quaternion::NlerpEx)
// Member Overloads // Member Overloads
.Overload< void (Quaternion::*)(void) >(_SC("Generate"), &Quaternion::Generate) .Overload(_SC("Generate"), &Quaternion::Generate)
.Overload< void (Quaternion::*)(Val, Val) >(_SC("Generate"), &Quaternion::Generate) .Overload(_SC("Generate"), &Quaternion::GenerateB)
.Overload< void (Quaternion::*)(Val, Val, Val, Val, Val, Val, Val, Val) >(_SC("Generate"), &Quaternion::Generate) .Overload(_SC("Generate"), &Quaternion::GenerateR)
// Static Functions // Static Functions
.StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Quaternion >) .StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Quaternion >)
.StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Quaternion >) .StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Quaternion >)

View File

@ -334,17 +334,17 @@ struct Quaternion
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance. * Generate random values for all components of this instance.
*/ */
void Generate(); Quaternion & Generate();
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance within the specified bounds. * Generate random values for all components of this instance within the specified bounds.
*/ */
void Generate(Value min, Value max); Quaternion & GenerateB(Value min, Value max);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance within the specified bounds. * Generate random values for all components of this instance within the specified bounds.
*/ */
void Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value wmin, Value wmax); Quaternion & GenerateR(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value wmin, Value wmax);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Clear the component values to default. * Clear the component values to default.

View File

@ -406,14 +406,16 @@ void Sphere::SetStr(SQChar delim, StackStrF & values)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Sphere::Generate() Sphere & Sphere::Generate()
{ {
pos.Generate(); pos.Generate();
rad = GetRandomFloat32(); rad = GetRandomFloat32();
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Sphere::Generate(Value min, Value max, bool r) Sphere & Sphere::GenerateB(Value min, Value max, bool r)
{ {
if (EpsLt(max, min)) if (EpsLt(max, min))
{ {
@ -425,31 +427,37 @@ void Sphere::Generate(Value min, Value max, bool r)
} }
else else
{ {
pos.Generate(min, max); pos.GenerateB(min, max);
} }
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Sphere::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax) Sphere & Sphere::GenerateR(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax)
{ {
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(zmax, zmin)) if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(zmax, zmin))
{ {
STHROWF("max value is lower than min value"); STHROWF("max value is lower than min value");
} }
pos.Generate(xmin, xmax, ymin, ymax, zmin, zmax); pos.GenerateR(xmin, xmax, ymin, ymax, zmin, zmax);
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Sphere::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value rmin, Value rmax) Sphere & Sphere::GenerateR2(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value rmin, Value rmax)
{ {
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(zmax, zmin) || EpsLt(rmax, rmin)) if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(zmax, zmin) || EpsLt(rmax, rmin))
{ {
STHROWF("max value is lower than min value"); STHROWF("max value is lower than min value");
} }
pos.Generate(xmin, xmax, ymin, ymax, zmin, zmax); pos.GenerateR(xmin, xmax, ymin, ymax, zmin, zmax);
rad = GetRandomFloat32(rmin, rmax); rad = GetRandomFloat32(rmin, rmax);
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -539,10 +547,10 @@ void Register_Sphere(HSQUIRRELVM vm)
.Func(_SC("Clear"), &Sphere::Clear) .Func(_SC("Clear"), &Sphere::Clear)
.FmtFunc(_SC("Format"), &Sphere::Format) .FmtFunc(_SC("Format"), &Sphere::Format)
// Member Overloads // Member Overloads
.Overload< void (Sphere::*)(void) >(_SC("Generate"), &Sphere::Generate) .Overload(_SC("Generate"), &Sphere::Generate)
.Overload< void (Sphere::*)(Val, Val, bool) >(_SC("Generate"), &Sphere::Generate) .Overload(_SC("Generate"), &Sphere::GenerateB)
.Overload< void (Sphere::*)(Val, Val, Val, Val, Val, Val) >(_SC("Generate"), &Sphere::Generate) .Overload(_SC("Generate"), &Sphere::GenerateR)
.Overload< void (Sphere::*)(Val, Val, Val, Val, Val, Val, Val, Val) >(_SC("Generate"), &Sphere::Generate) .Overload(_SC("Generate"), &Sphere::GenerateR2)
// Static Functions // Static Functions
.StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Sphere >) .StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Sphere >)
.StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Sphere >) .StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Sphere >)

View File

@ -379,22 +379,22 @@ struct Sphere
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate a randomly sized and positioned sphere. * Generate a randomly sized and positioned sphere.
*/ */
void Generate(); Sphere & Generate();
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate a randomly sized or positioned sphere within the specified bounds. * Generate a randomly sized or positioned sphere within the specified bounds.
*/ */
void Generate(Value min, Value max, bool r); Sphere & GenerateB(Value min, Value max, bool r);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate a randomly positioned sphere within the specified bounds. * Generate a randomly positioned sphere within the specified bounds.
*/ */
void Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax); Sphere & GenerateR(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate a randomly sized and positioned sphere within the specified bounds. * Generate a randomly sized and positioned sphere within the specified bounds.
*/ */
void Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value rmin, Value rmax); Sphere & GenerateR2(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value rmin, Value rmax);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Clear the component values to default. * Clear the component values to default.

View File

@ -330,14 +330,16 @@ void Vector2::SetStr(SQChar delim, StackStrF & values)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Vector2::Generate() Vector2 & Vector2::Generate()
{ {
x = GetRandomFloat32(); x = GetRandomFloat32();
y = GetRandomFloat32(); y = GetRandomFloat32();
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Vector2::Generate(Value min, Value max) Vector2 & Vector2::GenerateB(Value min, Value max)
{ {
if (EpsLt(max, min)) if (EpsLt(max, min))
{ {
@ -346,10 +348,12 @@ void Vector2::Generate(Value min, Value max)
x = GetRandomFloat32(min, max); x = GetRandomFloat32(min, max);
y = GetRandomFloat32(min, max); y = GetRandomFloat32(min, max);
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Vector2::Generate(Value xmin, Value xmax, Value ymin, Value ymax) Vector2 & Vector2::GenerateR(Value xmin, Value xmax, Value ymin, Value ymax)
{ {
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin)) if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin))
{ {
@ -358,6 +362,8 @@ void Vector2::Generate(Value xmin, Value xmax, Value ymin, Value ymax)
x = GetRandomFloat32(ymin, ymax); x = GetRandomFloat32(ymin, ymax);
y = GetRandomFloat32(xmin, xmax); y = GetRandomFloat32(xmin, xmax);
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -440,9 +446,9 @@ void Register_Vector2(HSQUIRRELVM vm)
.Func(_SC("Clear"), &Vector2::Clear) .Func(_SC("Clear"), &Vector2::Clear)
.FmtFunc(_SC("Format"), &Vector2::Format) .FmtFunc(_SC("Format"), &Vector2::Format)
// Member Overloads // Member Overloads
.Overload< void (Vector2::*)(void) >(_SC("Generate"), &Vector2::Generate) .Overload(_SC("Generate"), &Vector2::Generate)
.Overload< void (Vector2::*)(Val, Val) >(_SC("Generate"), &Vector2::Generate) .Overload(_SC("Generate"), &Vector2::GenerateB)
.Overload< void (Vector2::*)(Val, Val, Val, Val) >(_SC("Generate"), &Vector2::Generate) .Overload(_SC("Generate"), &Vector2::GenerateR)
// Static Functions // Static Functions
.StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Vector2 >) .StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Vector2 >)
.StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Vector2 >) .StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Vector2 >)

View File

@ -313,17 +313,17 @@ struct Vector2
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance. * Generate random values for all components of this instance.
*/ */
void Generate(); Vector2 & Generate();
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance within the specified bounds. * Generate random values for all components of this instance within the specified bounds.
*/ */
void Generate(Value min, Value max); Vector2 & GenerateB(Value min, Value max);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance within the specified bounds. * Generate random values for all components of this instance within the specified bounds.
*/ */
void Generate(Value xmin, Value xmax, Value ymin, Value ymax); Vector2 & GenerateR(Value xmin, Value xmax, Value ymin, Value ymax);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Clear the component values to default. * Clear the component values to default.

View File

@ -476,14 +476,16 @@ void Vector2i::SetStr(SQChar delim, StackStrF & values)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Vector2i::Generate() Vector2i & Vector2i::Generate()
{ {
x = GetRandomInt32(); x = GetRandomInt32();
y = GetRandomInt32(); y = GetRandomInt32();
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Vector2i::Generate(Value min, Value max) Vector2i & Vector2i::GenerateB(Value min, Value max)
{ {
if (max < min) if (max < min)
{ {
@ -492,10 +494,12 @@ void Vector2i::Generate(Value min, Value max)
x = GetRandomInt32(min, max); x = GetRandomInt32(min, max);
y = GetRandomInt32(min, max); y = GetRandomInt32(min, max);
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Vector2i::Generate(Value xmin, Value xmax, Value ymin, Value ymax) Vector2i & Vector2i::GenerateR(Value xmin, Value xmax, Value ymin, Value ymax)
{ {
if (xmax < xmin || ymax < ymin) if (xmax < xmin || ymax < ymin)
{ {
@ -504,6 +508,8 @@ void Vector2i::Generate(Value xmin, Value xmax, Value ymin, Value ymax)
x = GetRandomInt32(ymin, ymax); x = GetRandomInt32(ymin, ymax);
y = GetRandomInt32(xmin, xmax); y = GetRandomInt32(xmin, xmax);
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -586,9 +592,9 @@ void Register_Vector2i(HSQUIRRELVM vm)
.Func(_SC("Clear"), &Vector2i::Clear) .Func(_SC("Clear"), &Vector2i::Clear)
.FmtFunc(_SC("Format"), &Vector2i::Format) .FmtFunc(_SC("Format"), &Vector2i::Format)
// Member Overloads // Member Overloads
.Overload< void (Vector2i::*)(void) >(_SC("Generate"), &Vector2i::Generate) .Overload(_SC("Generate"), &Vector2i::Generate)
.Overload< void (Vector2i::*)(Val, Val) >(_SC("Generate"), &Vector2i::Generate) .Overload(_SC("Generate"), &Vector2i::GenerateB)
.Overload< void (Vector2i::*)(Val, Val, Val, Val) >(_SC("Generate"), &Vector2i::Generate) .Overload(_SC("Generate"), &Vector2i::GenerateR)
// Static Functions // Static Functions
.StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Vector2i >) .StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Vector2i >)
.StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Vector2i >) .StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Vector2i >)

View File

@ -418,17 +418,17 @@ struct Vector2i
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance. * Generate random values for all components of this instance.
*/ */
void Generate(); Vector2i & Generate();
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance within the specified bounds. * Generate random values for all components of this instance within the specified bounds.
*/ */
void Generate(Value min, Value max); Vector2i & GenerateB(Value min, Value max);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance within the specified bounds. * Generate random values for all components of this instance within the specified bounds.
*/ */
void Generate(Value xmin, Value xmax, Value ymin, Value ymax); Vector2i & GenerateR(Value xmin, Value xmax, Value ymin, Value ymax);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Clear the component values to default. * Clear the component values to default.

View File

@ -412,15 +412,17 @@ void Vector3::SetStr(SQChar delim, StackStrF & values)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Vector3::Generate() Vector3 & Vector3::Generate()
{ {
x = GetRandomFloat32(); x = GetRandomFloat32();
y = GetRandomFloat32(); y = GetRandomFloat32();
z = GetRandomFloat32(); z = GetRandomFloat32();
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Vector3::Generate(Value min, Value max) Vector3 & Vector3::GenerateB(Value min, Value max)
{ {
if (EpsLt(max, min)) if (EpsLt(max, min))
{ {
@ -430,10 +432,12 @@ void Vector3::Generate(Value min, Value max)
x = GetRandomFloat32(min, max); x = GetRandomFloat32(min, max);
y = GetRandomFloat32(min, max); y = GetRandomFloat32(min, max);
z = GetRandomFloat32(min, max); z = GetRandomFloat32(min, max);
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Vector3::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax) Vector3 & Vector3::GenerateR(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax)
{ {
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(zmax, zmin)) if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(zmax, zmin))
{ {
@ -443,6 +447,8 @@ void Vector3::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmi
x = GetRandomFloat32(xmin, xmax); x = GetRandomFloat32(xmin, xmax);
y = GetRandomFloat32(ymin, ymax); y = GetRandomFloat32(ymin, ymax);
z = GetRandomFloat32(zmin, zmax); z = GetRandomFloat32(zmin, zmax);
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -732,9 +738,9 @@ void Register_Vector3(HSQUIRRELVM vm)
.Func(_SC("RotateYZBy"), &Vector3::RotateYZBy) .Func(_SC("RotateYZBy"), &Vector3::RotateYZBy)
.Func(_SC("CenterRotateYZBy"), &Vector3::CenterRotateYZBy) .Func(_SC("CenterRotateYZBy"), &Vector3::CenterRotateYZBy)
// Member Overloads // Member Overloads
.Overload< void (Vector3::*)(void) >(_SC("Generate"), &Vector3::Generate) .Overload(_SC("Generate"), &Vector3::Generate)
.Overload< void (Vector3::*)(Val, Val) >(_SC("Generate"), &Vector3::Generate) .Overload(_SC("Generate"), &Vector3::GenerateB)
.Overload< void (Vector3::*)(Val, Val, Val, Val, Val, Val) >(_SC("Generate"), &Vector3::Generate) .Overload(_SC("Generate"), &Vector3::GenerateR)
// Static Functions // Static Functions
.StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Vector3 >) .StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Vector3 >)
.StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Vector3 >) .StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Vector3 >)

View File

@ -340,17 +340,17 @@ struct Vector3
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance. * Generate random values for all components of this instance.
*/ */
void Generate(); Vector3 & Generate();
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance within the specified bounds. * Generate random values for all components of this instance within the specified bounds.
*/ */
void Generate(Value min, Value max); Vector3 & GenerateB(Value min, Value max);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance within the specified bounds. * Generate random values for all components of this instance within the specified bounds.
*/ */
void Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax); Vector3 & GenerateR(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Clear the component values to default. * Clear the component values to default.

View File

@ -413,16 +413,18 @@ void Vector4::SetStr(SQChar delim, StackStrF & values)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Vector4::Generate() Vector4 & Vector4::Generate()
{ {
x = GetRandomFloat32(); x = GetRandomFloat32();
y = GetRandomFloat32(); y = GetRandomFloat32();
z = GetRandomFloat32(); z = GetRandomFloat32();
w = GetRandomFloat32(); w = GetRandomFloat32();
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Vector4::Generate(Value min, Value max) Vector4 & Vector4::GenerateB(Value min, Value max)
{ {
if (max < min) if (max < min)
{ {
@ -433,10 +435,12 @@ void Vector4::Generate(Value min, Value max)
y = GetRandomFloat32(min, max); y = GetRandomFloat32(min, max);
z = GetRandomFloat32(min, max); z = GetRandomFloat32(min, max);
y = GetRandomFloat32(min, max); y = GetRandomFloat32(min, max);
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Vector4::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value wmin, Value wmax) Vector4 & Vector4::GenerateR(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value wmin, Value wmax)
{ {
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(zmax, zmin) || EpsLt(wmax, wmin)) if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(zmax, zmin) || EpsLt(wmax, wmin))
{ {
@ -447,6 +451,8 @@ void Vector4::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmi
y = GetRandomFloat32(ymin, ymax); y = GetRandomFloat32(ymin, ymax);
z = GetRandomFloat32(zmin, zmax); z = GetRandomFloat32(zmin, zmax);
y = GetRandomFloat32(ymin, ymax); y = GetRandomFloat32(ymin, ymax);
// Allow chaining
return *this;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -541,9 +547,9 @@ void Register_Vector4(HSQUIRRELVM vm)
.Func(_SC("Clear"), &Vector4::Clear) .Func(_SC("Clear"), &Vector4::Clear)
.FmtFunc(_SC("Format"), &Vector4::Format) .FmtFunc(_SC("Format"), &Vector4::Format)
// Member Overloads // Member Overloads
.Overload< void (Vector4::*)(void) >(_SC("Generate"), &Vector4::Generate) .Overload(_SC("Generate"), &Vector4::Generate)
.Overload< void (Vector4::*)(Val, Val) >(_SC("Generate"), &Vector4::Generate) .Overload(_SC("Generate"), &Vector4::GenerateB)
.Overload< void (Vector4::*)(Val, Val, Val, Val, Val, Val, Val, Val) >(_SC("Generate"), &Vector4::Generate) .Overload(_SC("Generate"), &Vector4::GenerateR)
// Static Functions // Static Functions
.StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Vector4 >) .StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Vector4 >)
.StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Vector4 >) .StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Vector4 >)

View File

@ -338,17 +338,17 @@ struct Vector4
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance. * Generate random values for all components of this instance.
*/ */
void Generate(); Vector4 & Generate();
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance within the specified bounds. * Generate random values for all components of this instance within the specified bounds.
*/ */
void Generate(Value min, Value max); Vector4 & GenerateB(Value min, Value max);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Generate random values for all components of this instance within the specified bounds. * Generate random values for all components of this instance within the specified bounds.
*/ */
void Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value wmin, Value wmax); Vector4 & GenerateR(Value xmin, Value xmax, Value ymin, Value ymax, Value zmin, Value zmax, Value wmin, Value wmax);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Clear the component values to default. * Clear the component values to default.