data oriented design in games · title: data oriented design in games author: christian thuresson...

16
Strictly Confidential. Copyright © 2017 Electronic Arts DATA ORIENTED DESIGN IN GAMES Christian Dahlberg, Gameplay Engineer

Upload: others

Post on 03-May-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Data oriented design in games · Title: Data oriented design in games Author: Christian Thuresson Created Date: 6/7/2018 7:36:09 PM

Strictly Confidential. Copyright © 2017 Electronic Arts

DATA ORIENTED DESIGN IN GAMES

Chr ist ian Dahlberg , Gameplay Eng ineer

Page 2: Data oriented design in games · Title: Data oriented design in games Author: Christian Thuresson Created Date: 6/7/2018 7:36:09 PM

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

Page 3: Data oriented design in games · Title: Data oriented design in games Author: Christian Thuresson Created Date: 6/7/2018 7:36:09 PM

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

Page 4: Data oriented design in games · Title: Data oriented design in games Author: Christian Thuresson Created Date: 6/7/2018 7:36:09 PM

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

Page 5: Data oriented design in games · Title: Data oriented design in games Author: Christian Thuresson Created Date: 6/7/2018 7:36:09 PM

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

Page 6: Data oriented design in games · Title: Data oriented design in games Author: Christian Thuresson Created Date: 6/7/2018 7:36:09 PM

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

Page 7: Data oriented design in games · Title: Data oriented design in games Author: Christian Thuresson Created Date: 6/7/2018 7:36:09 PM

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)

Page 8: Data oriented design in games · Title: Data oriented design in games Author: Christian Thuresson Created Date: 6/7/2018 7:36:09 PM

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

Page 9: Data oriented design in games · Title: Data oriented design in games Author: Christian Thuresson Created Date: 6/7/2018 7:36:09 PM

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?

Page 10: Data oriented design in games · Title: Data oriented design in games Author: Christian Thuresson Created Date: 6/7/2018 7:36:09 PM

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?

Page 11: Data oriented design in games · Title: Data oriented design in games Author: Christian Thuresson Created Date: 6/7/2018 7:36:09 PM

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

Page 12: Data oriented design in games · Title: Data oriented design in games Author: Christian Thuresson Created Date: 6/7/2018 7:36:09 PM

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

Page 13: Data oriented design in games · Title: Data oriented design in games Author: Christian Thuresson Created Date: 6/7/2018 7:36:09 PM

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

Page 14: Data oriented design in games · Title: Data oriented design in games Author: Christian Thuresson Created Date: 6/7/2018 7:36:09 PM

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

Page 15: Data oriented design in games · Title: Data oriented design in games Author: Christian Thuresson Created Date: 6/7/2018 7:36:09 PM

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

Page 16: Data oriented design in games · Title: Data oriented design in games Author: Christian Thuresson Created Date: 6/7/2018 7:36:09 PM

Strictly Confidential. Copyright © 2017 Electronic Arts

THANK YOU!