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
bool (*functions[])() = | |
{ | |
Function0, | |
Function1, | |
Function2, | |
}; | |
bool LogicalAnd() | |
{ | |
for (auto f : functions) |
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
string rpAsset = ""; | |
if (GraphicsSettings.renderPipelineAsset != null) | |
rpAsset = GraphicsSettings.renderPipelineAsset.GetType().Name; | |
if (rpAsset.Equals("HDRenderPipelineAsset")) | |
renderPipeline = RenderPipeline.HDRP; | |
else if (rpAsset.Equals("UniversalRenderPipelineAsset")) | |
renderPipeline = RenderPipeline.URP; | |
else | |
renderPipeline = RenderPipeline.BuiltIn; |
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
float3 quantize(float3 p, float cellSize, float strength) | |
{ | |
float3 r = p / cellSize; | |
float3 f = floor(r); | |
float3 t = r - f; | |
return (f + smoothstep(0.0f, 1.0f, strength * (t - 0.5f) + 0.5f)) * cellSize; | |
} |
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
Vector3 inputVec = Vector3.zero; | |
if (Input.GetKey(KeyCode.UpArrow)) | |
inputVec += Vector3.up; | |
if (Input.GetKey(KeyCode.DownArrow)) | |
inputVec += Vector3.down; | |
if (Input.GetKey(KeyCode.LeftArrow)) | |
inputVec += Vector3.left; |
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
// example of how to move a current value towards a target value at a constant speed | |
// without going over the target value | |
// formula is the same for vectors of any dimension | |
Vector3 Seek(Vector3 currentValue, Vector3 targetValue, float maxSpeed, float dt) | |
{ | |
// delta/difference from current value to target value | |
Vector3 delta = targetValue - currentValue; | |
// don't take the square root of magnitude yet | |
// so we can potentially early out on degenerate case of currenvValue ~= targetValue |
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; | |
} |
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
(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
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
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; |
NewerOlder