This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void DrawFan(Vector3 o, Vector3 a, Vector3 b, uint numSegments) | |
{ | |
a.Normalize(); | |
b.Normalize(); | |
Vector3 axis = Vector3.Cross(a, b); | |
float angle = Mathf.Acos(Vector3.Dot(a, b)) * Mathf.Rad2Deg; | |
float deltaAngle = angle / numSegments; | |
Quaternion q = Quaternion.AngleAxis(deltaAngle, axis); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int lastUpdateSector = 0; | |
void Update() | |
{ | |
xRotation = Mathf.Repeat(xRotation, 360.0f); | |
int currentSector = (int) (xRotation / 45.0f); | |
if (currentSector != lastUpdate) | |
{ | |
int n = lastUpdateSector - currentSector; | |
n = (n >= 0) ? n : -n; | |
if (n > 4) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct Aabb | |
{ | |
public Vector2 Min; | |
public Vector2 Max; | |
public Aabb(Vector2 min, Vector2 max) | |
{ | |
Min = min; | |
Max = max; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define BEGIN_TEST_DEFINES static const int testIndexCounterBase = __COUNTER__ | |
#define END_TEST_DEFINES static const int kNumTests = (__COUNTER__ - testIndexCounterBase - 1) | |
#define TEST_CASE(TestName) \ | |
static const int k##TestName##Index = __COUNTER__ - testIndexCounterBase - 1; \ | |
bool TestName##Func(TestArgs &args) | |
struct TestEval | |
{ | |
int m_testIndex; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TEST_EVAL_LIST(myTests) | |
{ | |
TEST_EVAL(MyTest0), | |
TEST_EVAL(MyTest1), | |
// ... | |
} | |
RunTests(myTests, ARRAY_COUNT(myTests), args, passBits); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<GameObject> sprites; | |
List<GameObject> nameTextFields; | |
for (int i = 0, n = sprites.Length; i < n; ++i) | |
{ | |
var s = sprites[i]; | |
var ntf = nameTextFields[i]; | |
int row = i / numCols; | |
int col = i % numCols; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var table = new LookupTable(); | |
var pistol = | |
new WeaponEntry | |
( | |
name = "pistol", | |
damage = 10 | |
); | |
var shotgun = | |
new WeaponEntry | |
( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(export-weapon-damage-table | |
(pistol :damage 10) | |
(shotgun :damage 50) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Vector3 ClampBend(Vector3 vector, Vector3 reference, float maxBendAngle) | |
{ | |
float vectorLenSqr = vector.sqrMagnitude; | |
if (vectorLenSqr < MathUtil.Epsilon) | |
return vector; | |
float referenceLenSqr = reference.sqrMagnitude; | |
if (referenceLenSqr < MathUtil.Epsilon) | |
return vector; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Vector3 GetAxis(Quaternion q) | |
{ | |
Vector3 v = new Vector3(q.x, q.y, q.z); | |
float len = v.magnitude; | |
if (len < MathUtil.Epsilon) | |
return Vector3.left; | |
return v / len; | |
} |
OlderNewer