Skip to content

Commit

Permalink
Merge branch 'release/v0.7.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ColdenCullen committed Apr 30, 2014
2 parents a3242a3 + 2c7f56c commit 9be94ba
Show file tree
Hide file tree
Showing 15 changed files with 165 additions and 170 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Dash Logo](https://cloud.githubusercontent.com/assets/512416/2726786/6618d624-c5c2-11e3-9049-23637e5a1739.png)](https://github.com/Circular-Studios/Dash/wiki)

# [![Build Status](http://img.shields.io/travis/Circular-Studios/Dash/develop.svg?style=flat)](https://travis-ci.org/Circular-Studios/Dash) [![Docs](http://img.shields.io/badge/docs-ddoc-yellow.svg?style=flat)](http://circular-studios.github.io/Dash/docs/v0.6.6) [![Gitter Chat](http://img.shields.io/badge/chat-gitter-brightgreen.svg?style=flat)](https://gitter.im/Circular-Studios/Dash) [![Release](http://img.shields.io/github/release/Circular-Studios/Dash.svg?style=flat)](http://code.dlang.org/packages/dash)
# [![Build Status](http://img.shields.io/travis/Circular-Studios/Dash/develop.svg?style=flat)](https://travis-ci.org/Circular-Studios/Dash) [![Docs](http://img.shields.io/badge/docs-ddoc-yellow.svg?style=flat)](http://circular-studios.github.io/Dash/docs/v0.7.0) [![Gitter Chat](http://img.shields.io/badge/chat-gitter-brightgreen.svg?style=flat)](https://gitter.im/Circular-Studios/Dash) [![Release](http://img.shields.io/github/release/Circular-Studios/Dash.svg?style=flat)](http://code.dlang.org/packages/dash)

If you're reading this page, chances are you fall into one of the following categories:

Expand Down
55 changes: 29 additions & 26 deletions source/components/animation.d
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public:
{
// Update currentanimtime based on deltatime and animations fps
_currentAnimTime += Time.deltaTime * 24.0f;

if( _currentAnimTime >= 96.0f )
if( _currentAnimTime >= 95.0f )
{
_currentAnimTime = 0.0f;
}
Expand Down Expand Up @@ -269,37 +269,40 @@ public:
void fillTransforms( shared mat4[] transforms, shared Bone bone, shared float time, shared mat4 parentTransform )
{
shared mat4 finalTransform;
if( bone.positionKeys.length == 0 && bone.rotationKeys.length == 0 && bone.scaleKeys.length == 0 )
{
finalTransform = parentTransform * bone.nodeOffset;
transforms[ bone.boneNumber ] = finalTransform * bone.offset;
}
else
if(bone)
{
shared mat4 boneTransform = mat4.identity;

if( bone.positionKeys.length > cast(int)time )
if( bone.positionKeys.length == 0 && bone.rotationKeys.length == 0 && bone.scaleKeys.length == 0 )
{
boneTransform = boneTransform.translation( bone.positionKeys[ cast(int)time ].vector[ 0 ], bone.positionKeys[ cast(int)time ].vector[ 1 ],
bone.positionKeys[ cast(int)time ].vector[ 2 ] );
finalTransform = parentTransform * bone.nodeOffset;
transforms[ bone.boneNumber ] = finalTransform * bone.offset;
}
if( bone.rotationKeys.length > cast(int)time )
else
{
boneTransform = boneTransform * bone.rotationKeys[ cast(int)time ].to_matrix!( 4, 4 );
shared mat4 boneTransform = mat4.identity;

if( bone.positionKeys.length > cast(int)time )
{
boneTransform = boneTransform.translation( bone.positionKeys[ cast(int)time ].vector[ 0 ], bone.positionKeys[ cast(int)time ].vector[ 1 ],
bone.positionKeys[ cast(int)time ].vector[ 2 ] );
}
if( bone.rotationKeys.length > cast(int)time )
{
boneTransform = boneTransform * bone.rotationKeys[ cast(int)time ].to_matrix!( 4, 4 );
}
if( bone.scaleKeys.length > cast(int)time )
{
boneTransform = boneTransform.scale( bone.scaleKeys[ cast(int)time ].vector[ 0 ], bone.scaleKeys[ cast(int)time ].vector[ 1 ], bone.scaleKeys[ cast(int)time ].vector[ 2 ] );
}

finalTransform = parentTransform * boneTransform;
transforms[ bone.boneNumber ] = finalTransform * bone.offset;
}
if( bone.scaleKeys.length > cast(int)time )

// Check children
for( int i = 0; i < bone.children.length; i++ )
{
boneTransform = boneTransform.scale( bone.scaleKeys[ cast(int)time ].vector[ 0 ], bone.scaleKeys[ cast(int)time ].vector[ 1 ], bone.scaleKeys[ cast(int)time ].vector[ 2 ] );
fillTransforms( transforms, bone.children[ i ], time, finalTransform );
}

finalTransform = parentTransform * boneTransform;
transforms[ bone.boneNumber ] = finalTransform * bone.offset;
}

// Check children
for( int i = 0; i < bone.children.length; i++ )
{
fillTransforms( transforms, bone.children[ i ], time, finalTransform );
}
}

Expand Down
76 changes: 34 additions & 42 deletions source/components/assets.d
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,26 @@ public:
*/
final shared(T) get( T )( string name ) if( is( T == Mesh ) || is( T == Texture ) || is( T == Material ) || is( T == AssetAnimation ))
{
enum get( string array ) = q{
if( auto result = name in $array )
enum get( Type, string array ) = q{
static if( is( T == $Type ) )
{
result.isUsed = true;
return *result;
if( auto result = name in $array )
{
result.isUsed = true;
return *result;
}
else
{
logFatal( "Unable to find ", name, " in $array." );
return null;
}
}
else
{
logFatal( "Unable to find ", name, " in $array." );
return null;
}
}.replace( "$array", array );
static if( is( T == Mesh ) )
{
mixin( get!q{meshes} );
}
else static if( is( T == Texture ) )
{
mixin( get!q{textures} );
}
else static if( is( T == Material ) )
{
mixin( get!q{materials} );
}
else static if( is( T == AssetAnimation ) )
{
mixin( get!q{animations} );
}
else static assert( false, "Material of type " ~ T.stringof ~ " is not maintained by Assets." );
}.replaceMap( [ "$array": array, "$Type": Type.stringof ] );

mixin( get!( Mesh, q{meshes} ) );
mixin( get!( Texture, q{textures} ) );
mixin( get!( Material, q{materials} ) );
mixin( get!( AssetAnimation, q{animations} ) );
}

/**
Expand All @@ -80,19 +71,19 @@ public:
assert(aiIsExtensionSupported(".fbx".toStringz), "fbx format isn't supported by assimp instance!");

// Load the unitSquare
unitSquare = new shared Mesh( "", aiImportFileFromMemory(unitSquareMesh.toStringz, unitSquareMesh.length,
aiProcess_CalcTangentSpace | aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices | aiProcess_SortByPType,
"obj" ).mMeshes[0] );
unitSquare = new shared Mesh( "", aiImportFileFromMemory(
unitSquareMesh.toStringz, unitSquareMesh.length,
aiProcess_CalcTangentSpace | aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices | aiProcess_SortByPType,
"obj" ).mMeshes[0] );

foreach( file; FilePath.scanDirectory( FilePath.Resources.Meshes ) )
{
// Load mesh
const aiScene* scene = aiImportFile( file.fullPath.toStringz,
aiProcess_CalcTangentSpace | aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices | aiProcess_SortByPType );
//| aiProcess_FlipWindingOrder );
assert(scene, "Failed to load scene file '" ~ file.fullPath ~ "' Error: " ~ aiGetErrorString().fromStringz);
aiProcess_CalcTangentSpace | aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices | aiProcess_SortByPType );
assert( scene, "Failed to load scene file '" ~ file.fullPath ~ "' Error: " ~ aiGetErrorString().fromStringz );

// If animation data, add animation
if( file.baseFileName in meshes )
Expand Down Expand Up @@ -144,8 +135,8 @@ public:
*/
final void shutdown()
{
enum shutdownAA( string aaName, string friendlyName ) = q{
foreach_reverse( name; meshes.keys )
enum shutdown( string aaName, string friendlyName ) = q{
foreach_reverse( name; $aaName.keys )
{
if( !$aaName[ name ].isUsed )
logWarning( "$friendlyName ", name, " not used during this run." );
Expand All @@ -154,14 +145,15 @@ public:
$aaName.remove( name );
}
}.replaceMap( [ "$aaName": aaName, "$friendlyName": friendlyName ] );
mixin( shutdownAA!( q{meshes}, "Mesh" ) );
mixin( shutdownAA!( q{textures}, "Texture" ) );
mixin( shutdownAA!( q{materials}, "Material" ) );
mixin( shutdownAA!( q{animations}, "Animation" ) );

mixin( shutdown!( q{meshes}, "Mesh" ) );
mixin( shutdown!( q{textures}, "Texture" ) );
mixin( shutdown!( q{materials}, "Material" ) );
mixin( shutdown!( q{animations}, "Animation" ) );
}
}

/// TODO
/// Obj for a 1x1 square billboard mesh
immutable string unitSquareMesh = q{
v -1.0 1.0 0.0
v -1.0 -1.0 0.0
Expand Down
3 changes: 0 additions & 3 deletions source/core/prefabs.d
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ public:

/**
* Creates a GameObject instance from the prefab.
*
* Params:
* scriptOverride = Create the instance from this class type instead of the prefab's default.
*
* Returns:
* The new GameObject from the Prefab.
Expand Down
59 changes: 29 additions & 30 deletions source/graphics/adapters/adapter.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* TODO
* Contains all core code for the Graphics adapters, which is similar across all platforms
*/
module graphics.adapters.adapter;
import core, components, graphics, utility;
Expand All @@ -10,7 +10,7 @@ import derelict.opengl3.gl3;
import std.algorithm, std.array;

/**
* TODO
* Base class for core rendering logic
*/
abstract class Adapter
{
Expand All @@ -30,61 +30,61 @@ private:
shared UserInterface[] uis;

public:
/// TODO
/// GL DeviceContext
mixin( Property!_deviceContext );
/// TODO
/// GL RenderContext
mixin( Property!_renderContext );

/// TODO
/// Pixel width of the rendering area
mixin( Property!_width );
/// TODO
/// Pixel width of the actual window
mixin( Property!_screenWidth );
/// TODO
/// Pixel height of the rendering area
mixin( Property!_height );
/// TODO
/// Pixel height of the actual window
mixin( Property!_screenHeight );
/// TODO
/// If the screen properties match the rendering dimensions
mixin( Property!_fullscreen );
/// TODO
/// Hiding backsides of triangles
mixin( Property!_backfaceCulling );
/// TODO
/// Vertical Syncing
mixin( Property!_vsync );
/// TODO
/// FBO for deferred render textures
mixin( Property!_deferredFrameBuffer );
/// TODO
/// Texture storing the Diffuse colors and Specular Intensity
mixin( Property!_diffuseRenderTexture );
/// TODO
/// Texture storing the Sphermapped Normal XY and the Object ID in Z
mixin( Property!_normalRenderTexture );
/// TODO
/// Texture storing the depth
mixin( Property!_depthRenderTexture );

/**
* TODO
* Initializes the Adapter, called in loading
*/
abstract void initialize();
/**
* TODO
* Shuts down the Adapter
*/
abstract void shutdown();
/**
* TODO
* Resizes the window and updates FBOs
*/
abstract void resize();
/**
* TODO
* Reloads the Adapter without closing
*/
abstract void reload();
/**
* TODO
* Swaps the back buffer to the screen
*/
abstract void swapBuffers();

/**
* TODO
* Opens the window
*/
abstract void openWindow();
/**
* TODO
* Closes the window
*/
abstract void closeWindow();

Expand All @@ -94,7 +94,7 @@ public:
abstract void messageLoop();

/**
* TODO
* Initializes the FBO and Textures for deferred rendering
*/
final void initializeDeferredRendering()
{
Expand Down Expand Up @@ -172,8 +172,7 @@ public:
}

/**
* Called after all desired objects are drawn.
* Handles lighting and post processing.
* Currently the entire rendering pass for the active Scene. TODO: Refactor the name
*/
final void endDraw()
{
Expand Down Expand Up @@ -211,7 +210,7 @@ public:
shared mat4 invProj = scene.camera.inversePerspectiveMatrix;

/**
* TODO
* Pass for all objects with Meshes
*/
void geometryPass()
{
Expand Down Expand Up @@ -260,12 +259,12 @@ public:
}

/**
* TODO
* Pass for all objects with lights
*/
void lightPass()
{
/**
* TODO
* Binds the FBO textures to the shader
*/
void bindGeometryOutputs( Shader shader )
{
Expand Down Expand Up @@ -365,7 +364,7 @@ public:
}

/**
* TODO
* Draw the UI
*/
void uiPass()
{
Expand Down Expand Up @@ -430,7 +429,7 @@ public:

protected:
/**
* TODO
* Loads rendering properties from Config
*/
final void loadProperties()
{
Expand Down
8 changes: 4 additions & 4 deletions source/graphics/graphics.d
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/**
* TODO
* Container for the graphics adapter needed for the appropriate platform
*/
module graphics.graphics;
import graphics.adapters, graphics.shaders;

/**
* TODO
* Abstract class to store the appropriate Adapter
*/
final abstract class Graphics
{
public static:
/// TODO
/// The active Adapter
Adapter adapter;
/// TODO
/// Aliases adapter to Graphics
alias adapter this;

/**
Expand Down
Loading

0 comments on commit 9be94ba

Please sign in to comment.