45
45
#include < common/tess_renderer.h>
46
46
47
47
// Defold Rive Renderer
48
- #include " renderer.h"
49
-
50
- #include < private/defold_graphics.h>
48
+ #include < defold/renderer.h>
49
+ #include < defold/defold_graphics.h>
51
50
52
51
// DMSDK
53
52
#include < dmsdk/script.h>
@@ -235,6 +234,26 @@ namespace dmRive
235
234
return GetComponentFromIndex (world, index );
236
235
}
237
236
237
+ static void InstantiateArtboard (RiveComponent* component)
238
+ {
239
+ dmRive::RiveSceneData* data = (dmRive::RiveSceneData*) component->m_Resource ->m_Scene ->m_Scene ;
240
+
241
+ if (component->m_Resource ->m_DDF ->m_Artboard )
242
+ {
243
+ component->m_ArtboardInstance = data->m_File ->artboardNamed (component->m_Resource ->m_DDF ->m_Artboard );
244
+
245
+ if (!component->m_ArtboardInstance )
246
+ {
247
+ dmLogWarning (" Could not find artboard with name '%s'" , component->m_Resource ->m_DDF ->m_Artboard );
248
+ }
249
+ }
250
+
251
+ if (!component->m_ArtboardInstance )
252
+ {
253
+ component->m_ArtboardInstance = data->m_File ->artboardDefault ();
254
+ }
255
+ }
256
+
238
257
dmGameObject::CreateResult CompRiveCreate (const dmGameObject::ComponentCreateParams& params)
239
258
{
240
259
RiveWorld* world = (RiveWorld*)params.m_World ;
@@ -263,22 +282,8 @@ namespace dmRive
263
282
component->m_DoRender = 0 ;
264
283
component->m_RenderConstants = 0 ;
265
284
266
- dmRive::RiveSceneData* data = (dmRive::RiveSceneData*) component->m_Resource ->m_Scene ->m_Scene ;
267
-
268
- if (component->m_Resource ->m_DDF ->m_Artboard )
269
- {
270
- component->m_ArtboardInstance = data->m_File ->artboardNamed (component->m_Resource ->m_DDF ->m_Artboard );
285
+ InstantiateArtboard (component);
271
286
272
- if (!component->m_ArtboardInstance )
273
- {
274
- dmLogWarning (" Could not find artboard with name '%s'" , component->m_Resource ->m_DDF ->m_Artboard );
275
- }
276
- }
277
-
278
- if (!component->m_ArtboardInstance )
279
- {
280
- component->m_ArtboardInstance = data->m_File ->artboardDefault ();
281
- }
282
287
component->m_ArtboardInstance ->advance (0 .0f );
283
288
284
289
if (component->m_Resource ->m_CreateGoBones )
@@ -578,7 +583,7 @@ namespace dmRive
578
583
return dmGameObject::CREATE_RESULT_OK;
579
584
}
580
585
581
- static bool GetSender (RiveComponent* component, dmMessage::URL* out_sender)
586
+ static bool GetSender (RiveComponent* component, dmMessage::URL* out_sender)
582
587
{
583
588
dmMessage::URL sender;
584
589
sender.m_Socket = dmGameObject::GetMessageSocket (dmGameObject::GetCollection (component->m_Instance ));
@@ -603,7 +608,6 @@ namespace dmRive
603
608
604
609
component->m_AnimationInstance .reset ();
605
610
component->m_StateMachineInstance .reset ();
606
-
607
611
component->m_StateMachineInputs .SetSize (0 );
608
612
}
609
613
@@ -1030,11 +1034,14 @@ namespace dmRive
1030
1034
CompRiveAnimationReset (component);
1031
1035
CompRiveClearCallback (component);
1032
1036
1037
+ // For now, we need to create a new state machine instance when playing a state machine, because of nested artboards+state machine events
1038
+ InstantiateArtboard (component);
1039
+
1033
1040
component->m_Callback = callback_info;
1034
1041
component->m_CallbackId ++;
1035
1042
component->m_AnimationInstance = nullptr ;
1036
- component->m_StateMachineInstance = component->m_ArtboardInstance ->stateMachineAt (state_machine_index);
1037
1043
component->m_AnimationPlaybackRate = playback_rate;
1044
+ component->m_StateMachineInstance = component->m_ArtboardInstance ->stateMachineAt (state_machine_index);
1038
1045
1039
1046
// update the list of current state machine inputs
1040
1047
uint32_t count = component->m_StateMachineInstance ->inputCount ();
0 commit comments