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
| vec3 cuteSort(vec3 n) { | |
| float a = min(min(n.x, n.y), n.z); | |
| float b = max(max(n.x, n.y), n.z); | |
| return vec3(a, n.x + n.y + n.z - a - b, b); | |
| } |
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
| b = 1 << i; | |
| x = (0x287A & b) != 0 | |
| y = (0x02AF & b) != 0 | |
| z = (0x31E3 & b) != 0 |
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
| macro CANVAS_SET_ALPHA col { ; prepare mmx registers (alpha) by col (0xAAxxxxxx) | |
| push col | |
| shr col, 24 | |
| pxor mm5, mm5 | |
| movd mm7, col | |
| pshufw mm7, mm7, 0 | |
| neg col | |
| add col, 256 | |
| movd mm6, col | |
| pshufw mm6, mm6, 0 |
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
| float powf_fast(float a, float b) { | |
| union { float d; int x; } u = { a }; | |
| u.x = (int)(b * (u.x - 1064866805) + 1064866805); | |
| return u.d; | |
| } |
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
| mode out color out alpha | |
| -------------- -------------- ----------- | |
| layer/over: ( sc+(1-sa)*dc , sa+da-sa*da ) | |
| multiply: ( sc*dc , sa+da-sa*da ) | |
| screen: ( sa*da - (da-dc)*(sa-sc) , sa+da-sa*da ) | |
| lighten: ( max(sa*dc,sc*da) , sa+da-sa*da ) | |
| darken: ( min(sa*dc,sc*da) , sa+da-sa*da ) | |
| add: ( min(dc+sc,1) , min(sa+da,1) ) | |
| subtract: ( max(dc-sc,0) , min(sa+da,1) ) | |
| difference: ( abs(sa*dc-sc*da) , sa+da-sa*da ) |
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
| \S+\s*\r\n |
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
| uint32 blend(uint32 color1, uint32 color2, uint8 alpha) { | |
| uint32 rb = color1 & 0xff00ff; | |
| uint32 g = color1 & 0x00ff00; | |
| rb += ((color2 & 0xff00ff) - rb) * alpha >> 8; | |
| g += ((color2 & 0x00ff00) - g) * alpha >> 8; | |
| return (rb & 0xff00ff) | (g & 0xff00); | |
| } |
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
| TMat4f = {$IFDEF FPC} object {$ELSE} record {$ENDIF} | |
| private | |
| function GetPos: TVec3f; // https://gist.github.com/XProger/da9a74ae8b37905b421a | |
| procedure SetPos(const v: TVec3f); | |
| function GetRot: TQuat; // https://gist.github.com/XProger/def254d40a237cc0f0b2 | |
| procedure SetRot(const q: TQuat); | |
| public | |
| e00, e10, e20, e30, | |
| e01, e11, e21, e31, | |
| e02, e12, e22, e32, |
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
| TQuat = {$IFDEF FPC} object {$ELSE} record {$ENDIF} | |
| x, y, z, w : Single; | |
| {$IFNDEF FPC} | |
| class operator Equal(const q1, q2: TQuat): Boolean; | |
| class operator Add(const q1, q2: TQuat): TQuat; | |
| class operator Subtract(const q1, q2: TQuat): TQuat; | |
| class operator Multiply(const q: TQuat; x: Single): TQuat; | |
| class operator Multiply(const q1, q2: TQuat): TQuat; | |
| class operator Multiply(const q: TQuat; const v: TVec3f): TVec3f; | |
| {$ENDIF} |
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
| TVec3f = {$IFDEF FPC} object {$ELSE} record {$ENDIF} | |
| x, y, z : Single; | |
| {$IFNDEF FPC} | |
| class operator Equal(const a, b: TVec3f): Boolean; | |
| class operator Add(const a, b: TVec3f): TVec3f; | |
| class operator Subtract(const a, b: TVec3f): TVec3f; | |
| class operator Multiply(const a, b: TVec3f): TVec3f; | |
| class operator Multiply(const v: TVec3f; x: Single): TVec3f; | |
| {$ENDIF} | |
| function Dot(const v: TVec3f): Single; |