Skip to content

Commit 47ac621

Browse files
committed
Merge branch 'develop'
2 parents 0eea55a + bca1ede commit 47ac621

File tree

6 files changed

+46
-27
lines changed

6 files changed

+46
-27
lines changed

source/dash/components/component.d

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@ private:
359359
if( mixin( field.name ) != mixin( "new SerializationDescription()." ~ field.name ) )
360360
{
361361
// Deserialize it for the component
362-
mixin( "auto ser = "~field.serializer~".deserialize(this."~field.name~");" );
363-
// Copy the new value to the component
362+
mixin( "auto rep = cast("~field.serializer~".Rep)this."~field.name~";" );
363+
mixin( "auto ser = "~field.serializer~".deserialize(rep);" );
364364
mixin( "comp."~field.name~" = ser;" );
365365
}
366366
}
@@ -408,9 +408,17 @@ private:
408408
return attrs.join( ", " ).to!string;
409409
}
410410

411+
template SerializedType( T )
412+
{
413+
static if( is( T U : U[] ) )
414+
alias SerializedType = SerializedType!U;
415+
else
416+
alias SerializedType = T;
417+
}
418+
411419
// Get required module import name
412-
static if( __traits( compiles, moduleName!( typeof( member ) ) ) )
413-
enum modName = moduleName!(typeof(member));
420+
static if( __traits( compiles, moduleName!( SerializedType!memberType ) ) )
421+
enum modName = moduleName!( SerializedType!memberType );
414422
else
415423
enum modName = null;
416424

source/dash/core/gameobject.d

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ public:
528528
* and can generate a World matrix, worldPosition/Rotation (based on parents' transforms)
529529
* as well as forward, up, and right axes based on rotation
530530
*/
531-
private struct Transform
531+
struct Transform
532532
{
533533
private:
534534
vec3f _prevPos;
@@ -543,12 +543,6 @@ private:
543543
scale = vec3f( desc.scale[] );
544544
}
545545

546-
void refresh( Description desc )
547-
{
548-
// TODO: Track if the transform actually changed.
549-
this = desc;
550-
}
551-
552546
/**
553547
* Default constructor, most often created by GameObjects.
554548
*
@@ -582,6 +576,12 @@ public:
582576
float[3] scale = [ 1.0f, 1.0f, 1.0f ];
583577
}
584578

579+
void refresh( Description desc )
580+
{
581+
// TODO: Track if the transform actually changed.
582+
this = desc;
583+
}
584+
585585
/**
586586
* Create a description from a Transform.
587587
*

source/dash/editor/events.d

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,21 @@ void registerObjectEvents( Editor ed, DGame game )
5454
throw new Exception( "Object " ~ req.objectName ~ " not found." );
5555
}
5656
} );
57+
58+
// Refresh a transform
59+
static struct TransformRefreshRequest
60+
{
61+
string objectName;
62+
Transform.Description description;
63+
}
64+
ed.registerEventHandler( "object:transform:refresh", ( TransformRefreshRequest req ) {
65+
if( auto obj = game.activeScene[ req.objectName ] )
66+
{
67+
obj.transform.refresh( req.description );
68+
}
69+
else
70+
{
71+
throw new Exception( "Object " ~ req.objectName ~ " not found." );
72+
}
73+
} );
5774
}

source/dash/utility/data/serialization.d

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ template serializeToFile( bool prettyPrint = true )
209209
/// Supported serialization formats.
210210
enum serializationFormats = tuple( "Json", "Bson", "Yaml" );
211211

212-
/// Type to use when defining custom
213-
struct CustomSerializer( _T, _Rep, alias _ser, alias _deser, alias _check = (_) => true )
212+
/// Type to use when defining custom
213+
struct CustomSerializer( _T, _Rep, alias _ser, alias _deser, alias _check )
214214
if( is( typeof( _ser( _T.init ) ) == _Rep ) &&
215215
is( typeof( _deser( _Rep.init ) ) == _T ) &&
216216
is( typeof( _check( _Rep.init ) ) == bool ) )
@@ -245,15 +245,8 @@ enum hasSerializer( T ) = anySatisfy!( isSerializerFor!T, customSerializers );
245245
/// Get the serializer for a type
246246
template serializerFor( T )
247247
{
248-
import dash.components.component;
249-
250248
static if( hasSerializer!T )
251249
alias serializerFor = Filter!( isSerializerFor!T, customSerializers )[ 0 ];
252-
else static if( is( T : Component ) )
253-
alias serializerFor = CustomSerializer!( T, ComponentReference,
254-
t => ComponentReference( componentMetadata!T.name, t.id ),
255-
r => getComponent( r.id ),
256-
r => !r.id.empty && t.name );
257250
else
258251
alias serializerFor = defaultSerializer!T;
259252
}

source/dash/utility/output.d

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@ final class DashEditorLogger : Logger
146146
{
147147
this()
148148
{
149-
import std.stdio: stdout;
150-
151149
// File not actually used for anything, but required by FileLogger
152150
super( LogLevel.all );
153151
}

source/dash/utility/time.d

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,16 @@ public:
5353
assert( onMainThread, "Must call Time.update from main thread." );
5454

5555
updateTime();
56+
57+
import dash.core.dgame: DGame;
58+
DGame.instance.editor.send( "dash:perf:frametime", deltaTime );
5659
}
5760

5861
private:
5962
this()
60-
{
61-
delta = total = Duration.zero;
62-
}
63+
{
64+
delta = total = Duration.zero;
65+
}
6366
}
6467

6568
private:
@@ -93,14 +96,14 @@ void updateTime()
9396
}
9497

9598
delta = cast(Duration)( cur - prev );
96-
99+
97100
prev = cur;
98101
cur = sw.peek();
99102

100103
// Pass to values
101104
Time.total = cast(Duration)cur;
102105
Time.delta = delta;
103-
106+
104107
// Update framerate
105108
++frameCount;
106109
second += delta;

0 commit comments

Comments
 (0)