data oriented design in games · title: data oriented design in games author: christian thuresson...
TRANSCRIPT
Strictly Confidential. Copyright © 2017 Electronic Arts
DATA ORIENTED DESIGN IN GAMES
Chr ist ian Dahlberg , Gameplay Eng ineer
Strictly Confidential. Copyright © 2017 Electronic Arts
GHOST GAMES
> EA studio based in Gothenburg
> Ghost made the three Last Need for Speed games
> Worked on Far Cry 3, NFS and NFS Payback
> Worked as a teacher at The Game Assembly
Strictly Confidential. Copyright © 2017 Electronic Arts
OBJECT ORIENTED DESIGN PROBLEMS
> Started simple
> Years has taught us the issues
> Not scalable
> Grows in complexity exponentially
Art Logic Game
Rendering
IO
Objects
GameplayScene
Animations
Physics
Strictly Confidential. Copyright © 2017 Electronic Arts
REAL LIFE IS A BAD EXAMPLE
> What are we taught in schools?
> Create objects based on reality
> Everything in an object in all functions of that object
> To share functionality use inheritance
> Interdependency between objects is synchronous
> This is bad for games
Strictly Confidential. Copyright © 2017 Electronic Arts
DATA ORIENTED DESIGN
> Create objects based on the data access of your systems
> This stops the data complexity problem from growing as fast
> Mike Acton – The purpose of all programs, and all parts of those programs, is to transform data from one form to another.
> If you don’t understand the data you don’t understand the problem
> The more data you have the more complex your problem is
Strictly Confidential. Copyright © 2017 Electronic Arts
ALL DATA AVAILABLE ALWAYS
> When all data is available you can solve any problem in any function or object
> This will scale poorly with team size
Rendering
IO
Objects
GameplayScene
Animations
Physics
Rendering
IO
Objects
GameplayScene
Animations
Physics
System process
Strictly Confidential. Copyright © 2017 Electronic Arts
RACE CONDITIONS
> When complexity is high you create race condition by accident all the time
> Thread issues are hard to reproduce
> Knowing the dependecy between threads is really difficult
> Race conditions are very hard to find
> We shipped with a lot of them(we can implement them in scripts)
Strictly Confidential. Copyright © 2017 Electronic Arts
REAL LIFE OBJECTS IN DATA ORIENTATION
> All objects consist of of components
> Every component is a class
> The real life object only exists in data and not in your code
Strictly Confidential. Copyright © 2017 Electronic Arts
Strictly Confidential. Copyright © 2017 Electronic Arts
COMPONENT SYSTEMS IN GAMES
> Components are sub-objects attached to Entities
> Dependencies between components in the same game object is the tricky part
> Memory traversal is harder to solve
> Linear memory traversal
Physics component Mesh Component
Code objects aka classes
Entity
Referenced by Id,Component to entity
Communication across coponents?
Strictly Confidential. Copyright © 2017 Electronic Arts
DOD NOT OOD
> Start thinking about the data that is your first problem not what objects
> Think about the following things:
> What data do you need for your system to work?
> What data do you want to be shared between systems?
> How many objects are you operating on?
> Is there any interdependency between objects?
Strictly Confidential. Copyright © 2017 Electronic Arts
SCRIPTING LANGUAGES
> Be scared!
in many scripting languages!
> Creates race conditions if run on mutliple threads or across network
Strictly Confidential. Copyright © 2017 Electronic Arts
WHAT IS THE GAME INDUSTRY DOING?
> Components as objects
> Real world objects are only a data construct
> Create scripts that can run in parallel
Strictly Confidential. Copyright © 2017 Electronic Arts
SMALL BESPOKE SYSTEMS
> Small bespoke makes it flexible
> Clearer interface
> More effective
> What can be done is more well defined
> Dependencies are what a game have to implement
> Ideally only data will be different between games
> Keeps divergence with the base systems low
Strictly Confidential. Copyright © 2017 Electronic Arts
CONCLUSION
> Don’t base your system on real life
> What data is shared and which is not
> How does your system traverse memory
Strictly Confidential. Copyright © 2017 Electronic Arts
Strictly Confidential. Copyright © 2017 Electronic Arts
WANT TO LEARN MORE?
> https://www.youtube.com/watch?v=rX0ItVEVjHc - CppCon 2014: Mike Acton "Data-Oriented Design and C++“
> https://www.youtube.com/watch?v=p65Yt20pw0g - Unity at GDC - A Data Oriented Approach to Using Component Systems
> https://www.youtube.com/watch?v=fHNmRkzxHWs CppCon 2014: Chandler Carruth "Efficiency with Algorithms, Performance with Data Structures"
> https://www.youtube.com/watch?v=ZHqFrNyLlpA Hands on example from Jonathan Blow
> http://www.dice.se/wp-content/uploads/2014/12/Introduction_to_Data-Oriented_Design.pdf
Strictly Confidential. Copyright © 2017 Electronic Arts
THANK YOU!