Presentation is loading. Please wait.

Presentation is loading. Please wait.

Reflection for Tools Development Senior Tools Programmer Ubisoft Vancouver Jeremy Walker.

Similar presentations


Presentation on theme: "Reflection for Tools Development Senior Tools Programmer Ubisoft Vancouver Jeremy Walker."— Presentation transcript:

1

2 Reflection for Tools Development Senior Tools Programmer Ubisoft Vancouver Jeremy Walker

3 Understanding the Costs of Tools Development The Ultimate Technique for Data Driven Solutions A Reflection-Powered Infrastructure for Tools Table of Contents

4

5 Hard Coded vs. Data Driven Systems Animation Hard Coded Animation System Animation Animation Tools Animation Build System Animation Engine Animation Serialization Hard Coded System Data Driven System

6 What's the Cost of Great Workflows? Scenes Scene Editing Tools Scene Build System Scene Rendering Engine Scene Serialization Animation Animation Tools Animation Build System Animation Engine Animation Serialization Sounds Sound Editing Tools Sound Build System Sound Playback Engine Sound Serialization

7 SHARED HUDAnimationSoundsCut ScenesInputFront EndCamerasParticlesCharactersTexturesAILevelsModelsShadersMaterialsPropsSkeletonsMusicSequencesState FlowsCurvesVideosScriptsScenes Great Workflows for All Types of Content

8 SHARED HUDAnimationSoundsCut ScenesInputFront EndCamerasParticlesCharactersTexturesAILevelsModelsShadersMaterialsPropsSkeletonsMusicSequencesState FlowsCurvesVideosScriptsScenes Hard Coded The Keep-It-Simple Approach Hard Coded

9 HUDAnimationSoundsCut ScenesInputFront EndCamerasParticlesCharactersTexturesAILevelsModelsShadersMaterialsPropsSkeletonsMusicSequencesState FlowsCurvesVideosScriptsScenes The Monolithic Engine Approach Monolithic Engine Animation, Sounds, Scenes, Input, Front End, Cameras, Particles, Characters, Textures, AI, Levels, Models, Shaders, Materials, HUD, Props, Skeletons, Music, Sequences, State Flows, Curves, Videos, Scripts, Cut Scenes

10 The Problem Low Development Cost Stable Tools Reusable Systems Great Workflows Adaptable To Change Game and Genre-Specific Needs

11 For all types of content: Minimize the cost of developing great workflows. Design reusable systems while accommodating game- specific needs. Develop stable tools that adapt to constant change during production. The Solution

12 The Package Release Cycle Source Code Automated Build Process OK? Release Candidate yes no Testing Process OK? yes no Release Artist Gets Package Release Programmer Modifies Code Artist Requests New Features

13 The Monolithic Package Release Problem Monolithic Package Source Code Monolithic Package Release

14 Package Release The Benefit of Decoupled Packages Package Source Code

15 Animation Tool Release Sound Tool Release Game Release The Lockstep Release Problem Animation Tool Source Code Sound Tool Source Code Game Source Code Compile Time Dependency Compile Time Dependency Lockstep Release Cycle Run Time Dependency Run Time Dependency

16 Decoupled Systems HUD Animation Sounds CamerasParticlesCharacter s Materials Props Scenes Decoupled Systems HUD Animation Sounds CamerasParticlesCharacter s Materials Props Scenes Reflection Reducing Cost and Complexity Hardcoded Engine Hard Coded Low Cost Simple Hard to Reuse Poor Workflow Monolithic Engine Animation, Sounds, Scenes, Input, Front End, Cameras, Particles, Characters, Textures, AI, Levels, Models, Shaders, Materials, HUD, Props, Skeletons, Music, Sequences, State Flows, Curves, Videos, Scripts, Cut Scenes Medium Cost Complex Reuse All or Nothing Great Workflow High Cost Very Complex Very Reusable Great Workflow

17

18 From Wikipedia: “…Reflection is the process by which a computer program can observe and modify its own structure and behaviour.” What is Reflection?

19 Reflection is Used Everywhere

20 Case Study: C++ Compilation C++CompilerC++Compiler Function B calls Function A Function B calls Function A Expose Discover Validate Implement Reflection Function Declaration Binding to Function Definition Function A C++CompilerC++Compiler

21 Reflection for Language Interoperability Visual Basic Compiler Compiler C# Code Expose Discover Validate Implement Reflection Type Definitions Type Binding Visual Basic Code C#CompilerC#Compiler

22 Reflection for Scripting in Games C++ Adapter Lua Script Expose Discover Validate Implement Type Definitions Type Binding C++ Classes Script Adapter Reflection

23 Reflection for Serialization in Games C++ Adapter Serialized Objects Expose Discover Validate Implement Type Definitions Type Binding C++ Classes SerializerSerializer Reflection

24 Common Language Specification Type Definitions Type Binding Reflection Type size and alignment Native types Classes Enums Allocate objects Binary representation Invoke constructor, get/invoke members Get/set enum value

25 const Type* type = TypeOf (); const char* name = type->Name(); size_t size = type->Size(); printf(“Type: %s\n Size: %d\n”, name, size); Instance vehicle = type->CreateInstance(); vehicle.As ().m_MaxSpeedKPH = f; for (int i=0; i NumMembers(); i++) { const Member* member = vehicle.GetMember(i); if (member->IsField()) { const Field* field = (Field*)member; if (field->GetType() == TypeOf ()) { Instance value = vehicle.GetField(field); printf(“Field: %s\n Offset: %d\n Value: %.2f\n”, field->Name(), field->Offset(), value.As ()); } Example: Print all fields of type “float” Reflection in Action Type: SimpleVehicle Size: 4 Field: MaxSpeedKPH Offset 0 Value: Output

26 Macros Code Parser Type Definition Language Popular Approaches to C++ Reflection

27 Reflection with Macros class SimpleVehicle : public Entity { public: DECLARE_TYPE(); floatm_MaxSpeedKPH; void Reset(bool useDefaults); float GetMaxSpeedMPH() const; voidSetMaxSpeedMPH(float maxSpeedMPH); }; //In a separate.CPP file: DEFINE_TYPE(SimpleVehicle) BASE_CLASS(Entity) FIELD(“MaxSpeedKPH”, m_MaxSpeedKPH) METHOD(Reset) PROPERTY(GetMaxSpeedMPH, SetMaxSpeedMPH) DEFINE_TYPE_END() Macros Example Pros No external tools Cons Awkward to implement Hard to debug Run-time discovery

28 Reflection with Code Parser /// [Class] class SimpleVehicle : public Entity { public: /// [Field(“MaxSpeedKPH”)] floatm_MaxSpeedKPH; /// [Method] void Reset(bool useDefaults); /// [Property] float GetMaxSpeedMPH() const; /// [Property] voidSetMaxSpeedMPH(float maxSpeedMPH); }; Code Parser Example Pros Easier to implement Compile-time discovery Cons Slow pre-build step

29 Reflection with Type Definition Language class SimpleVehicle : Entity { floatMaxSpeedKPH; void Reset(bool useDefaults); float MaxSpeedMPH { get; set; } }; Type Definition Language Example Pros Easiest to implement No slow pre-build Cons Can’t reflect existing classes

30 /// [Class] class SimpleVehicle : public Entity { public: /// [Field(“MaxSpeedKPH”)] floatm_MaxSpeedKPH; /// [Method] void Reset(bool useDefaults); /// [Property] float GetMaxSpeedMPH() const; /// [Property] voidSetMaxSpeedMPH(float maxSpeedMPH); }; C++ Class Types.xml Exporting Type Definitions for Game C++ Reflected Types (game-side) Code Parser Types.xml Generated Binder Code Reflection System (game-side)

31 Types.xml Exporting Type Definitions for Tools C++ Reflected Types (game-side) Code Parser Types.xml Reflection System (tool-side) C# Proxy Generator [ProxyType(“SimpleVehicle”, 0x81c37132)] public partial class SimpleVehicle : Entity { public float MaxSpeedKPH { get { return this.Instance.GetField(“MaxSpeedKPH”).Get (); } set { this.Instance.GetField(“MaxSpeedKPH”).Set (value); } } } public float MaxSpeedMPH {... } public void Reset(bool useDefaults) {... } } C# Proxy Class

32 Primary Uses for Reflection in Tools Types.xml Reflection System Serialization Generated UI (PropertyGrid, TreeView, etc.) Client-Server Remoting

33 Client-Server Remoting RemotingClientRemotingClient Generated C# Proxy Classes Expose Discover Validate Implement Reflection Type Definitions Type Binding C# Proxy Generator C++ Adapter Expose Discover Validate Implement Reflection Type Definitions Type Binding C++ Game Classes RemotingServerRemotingServer Tools (Client) Game (Server)

34 Type definitions out of sync Detect type checksum mismatch Detect problems early Auto-synchronization of type information Auto-migration of data Problems and Workarounds

35 Tools tightly coupled to the game Avoid overuse of generated proxy classes Use generated UI where possible Use polymorphic proxy classes Problems and Workarounds Tools Code Base Class Derived Class A Derived Class B Derived Class C has proxy has no proxy

36 Excessive memory usage Strip type information based on usage Auto-detect unused reflected types Problems and Workarounds

37 Marshalling events for multi-processor architectures Client-Server Remoting for Online Serialization of saved game data Other Uses for Reflection

38

39 Content Framework Build System Asset Repository Asset Manager Asset Explorer Package System Content Framework Reflection Tool-side Game-side Asset Previewing 3 rd Party

40 (Demo Videos)

41 Fast tools development Great workflows for all types of content Decoupled systems with improved reusability and resilience to change Promising Results

42 Questions?


Download ppt "Reflection for Tools Development Senior Tools Programmer Ubisoft Vancouver Jeremy Walker."

Similar presentations


Ads by Google