Huge demos update
-moved C stdlib function definitions to ecs_utils.utils -added function to calculate mix(linear interpolation) and rsqrt(fast inverse sqrt) -added some math to vec2 (length, normalize...) -improved renderer with possibility to use multiple materials (one per block, not perfect solution for parallel compute, but works with some requirements) -added blending support for material (opaque, additive, mixed) -added Android support -added gprahical representation for mouse tools (tool_circle.d) -added initial support for editing template components variables -better Component and Templates listing -added possibility to add/removes components using mouse -move CLocation to game_core.basic and reuse in every test -moved tools code from demos to App (now code is fully separated from demos!) -some improvement and fixes in Snake demo, with additional systems to handle adding and removing entities -added new demo: Particles. By now demo has several particles to spawn and support for attractors and vortexes (calculation is made as every attractor with every entity) -fixed bug with window hover and tools -improved tool behaviour -added new material -now window is always opened as maximized windowed mode -some minor fixes and improvements
This commit is contained in:
parent
13e6ed8fd5
commit
e76c5ccdb2
20 changed files with 1804 additions and 288 deletions
|
|
@ -2,13 +2,24 @@ module ecs_utils.utils;
|
|||
|
||||
extern(C):
|
||||
|
||||
int randomRange(int min, int max)
|
||||
import ecs_utils.math.vector;
|
||||
|
||||
enum PI = 3.141592653589793238462643383279502884197169399375105820;
|
||||
|
||||
extern(C) float sqrtf(float x) @nogc nothrow @system;
|
||||
extern(C) float acosf(float x) @nogc nothrow @system;
|
||||
extern(C) float sinf(float x) @nogc nothrow @system;
|
||||
extern(C) float cosf(float x) @nogc nothrow @system;
|
||||
extern(C) float powf(float x, float y) @nogc nothrow @system;
|
||||
extern(C) float fabs(float x) @nogc nothrow @system;
|
||||
|
||||
int randomRange(int min, int max) nothrow @nogc @trusted
|
||||
{
|
||||
int range = max - min;
|
||||
return rand() % range - min;
|
||||
}
|
||||
|
||||
float randomf()
|
||||
float randomf() nothrow @nogc @trusted
|
||||
{
|
||||
const float scale = 1.0 / 32_767.0;
|
||||
return cast(float)(rand() & 0x007FFF) * scale;
|
||||
|
|
@ -21,6 +32,38 @@ float randomRangef(float min, float max)
|
|||
return rand()%4096;
|
||||
}*/
|
||||
|
||||
float mix(float x, float y, float a)
|
||||
{
|
||||
//return x*a + y*(a-1);
|
||||
//return x*a + y*a - y;
|
||||
return x*(a+y) - y;
|
||||
}
|
||||
|
||||
float rsqrt(float number)
|
||||
{
|
||||
long i;
|
||||
float x2, y;
|
||||
const float threehalfs = 1.5F;
|
||||
|
||||
x2 = number * 0.5F;
|
||||
y = number;
|
||||
i = * cast( long * ) &y; // evil floating point bit level hacking
|
||||
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
|
||||
y = * cast( float * ) &i;
|
||||
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
vec2 randomCircularSample() nothrow @nogc @trusted
|
||||
{
|
||||
float angle = 2 * PI * randomf;
|
||||
float radius = sqrtf(randomf);
|
||||
float s = sinf(angle);
|
||||
float c = cosf(angle);
|
||||
return vec2(c,s)*radius;
|
||||
}
|
||||
|
||||
version(GNU)
|
||||
{
|
||||
public import core.stdc.stdio : printf;
|
||||
|
|
@ -34,7 +77,7 @@ else
|
|||
extern(C) int printf(scope const char* format, ...) @nogc nothrow @system;
|
||||
public import std.array : staticArray;
|
||||
}
|
||||
extern(C) int rand();
|
||||
extern(C) int rand() nothrow @nogc @trusted;
|
||||
|
||||
version(D_BetterC)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue