
CryEngine out on GitHub - lentil_soup
https://github.com/CRYTEK-CRYENGINE/CRYENGINE
======
NKCSS
This might be fun to look through; first thing I saw that I never thought of
before was how to define flag enums.

From [https://github.com/CRYTEK-
CRYENGINE/CRYENGINE/blob/release/C...](https://github.com/CRYTEK-
CRYENGINE/CRYENGINE/blob/release/Code/CryEngine/Cry3DEngine/BreakableGlassRenderNode.cpp):

    
    
        // State flags
        enum EGlassRNState
        {
        	EGlassRNState_Initial     = 0,
        	EGlassRNState_Weakened    = 1 << 0,
        	EGlassRNState_Shattering  = 1 << 1,
        	EGlassRNState_Shattered   = 1 << 2,
        	EGlassRNState_ActiveFrags = 1 << 3
        };
    

Als a C# dev, I write Enum flags from time to time, but I always just write
out the values; never thought of using bit-shifting to prevent typos :)

~~~
pkaye
In the Go language, there is something called iota which is like a iterator
that counts up from 0:

    
    
        type EGlassRNState int
    
        const (
            EGlassRNState_Initial EGlassRNState = 1 << iota
            EGlassRNState_Weakened
            EGlassRNState_Shattering
            EGlassRNState_Shattered
            EGlassRNState_ActiveFrags
        )

~~~
50CNT
In python you could probably do

    
    
        def makeflag():
            flag = 1
            while True:
                yield flag
                flag = flag << 1
        flag = makeflag()
        E_GLASS_RN_STATE_INITIAL = next(flag)
        E_GLASS_RN_STATE_WEAKENED = next(flag)
        E_GLASS_RN_STATE_SHATTERING = next(flag)
        E_GLASS_RN_STATE_ACTIVE_FRAGS = next(flag) 
    
        flag2 = makeflag()
        UNRELATED_FLAG = next(flag2) 
        UNRELATED_FLAG = next(flag2) 
        

Also no chance of fatfingering a number.

~~~
dalke
Another option is to assume at most 128 bits then do something like:

    
    
      >>> _bitflags = [1<<i for i in range(128)]
      >>> (E_GLASS_RN_STATE_INITIAL,
      ...  E_GLASS_RN_STATE_WEAKENED,
      ...  E_GLASS_RN_STATE_SHATTERING,
      ...  E_GLASS_RN_STATE_ACTIVE_FRAGS,
      ...  *rest) = _bitflags
      >>> E_GLASS_RN_STATE_ACTIVE_FRAGS
      8

------
zx2c4
Wow.

[https://github.com/CRYTEK-
CRYENGINE/CRYENGINE/blob/release/C...](https://github.com/CRYTEK-
CRYENGINE/CRYENGINE/blob/release/Code/CryEngine/CryPhysics/livingentity.cpp#L1300)

Intensity.

~~~
dagw
Carmack has some interesting comments on this sort of coding: [http://number-
none.com/blow/john_carmack_on_inlined_code.htm...](http://number-
none.com/blow/john_carmack_on_inlined_code.html)

~~~
butabah
Seeing Carmack's thoughts on programming always reminds me that I have such a
long way to go. When he was my age, he had already created DOOM and DOOM 2
(along with the wtf? r_sqrt trick).

~~~
corysama
Fun story: both ID and Epic started out making 2D games. When Tim Sweeny saw
Quake for the first time, he literally gave up on gamedev because he thought
he wouldn't be able to keep up with game tech. But, shortly afterwards a
friend of Tim wrote a Quake-like 3D renderer as a fun project. Tim figured if
that guy could do it, he could do it and went on the make Unreal.

~~~
damptowel
Is this true? There's leaked Unreal alpha stuff from 1995, which was already
doing almost everything Quake's bsp renderer ended up doing.

~~~
munchbunny
One important insight into all of this is that, while there might not have
been BSP renderers until 1995, the BSP rendering _algorithm_ was probably
10-20 years old at that point.

Another good example of this is the Phong shading model. IIRC it was invented
in the mid-70s, and some software rasterizers implemented it, but it didn't
really make its way into graphics cards with fixed pipeline rendering until
the mid-90s.

Graphics tech in the 90s and even early 2000s involved a lot of hardware and
software catching up to theory from the 70s and 80s because we were finally
getting enough compute power to make it worthwhile to use "approximate"
rasterization-based algorithms in order to get real-time rendering.

~~~
corysama
I had to dig up my source for this. I did misquote. It was Wolfenstein that
gave Tim a shakeup and it drove him from coding to management, not out of
games.

> Did you think about doing a first-person shooter after their success with
> Wolfenstein 3D and Doom?

> TS: It was funny how we got to that point. When I saw Wolfenstein for the
> first time, that was truly shocking. I'd never envisioned that you could do
> 3D in a computer game; I don't know why.

> The research had indicated that you could do that for at least 15 years
> before that, but it was this 3D game with real-time texture mapping; you
> know, real-time bitmaps scaled up and displayed in 3D on the screen. It
> never occurred to me that you could actually write code to do that. It was
> just another lack of foresight there.

> But seeing that for the first time, I was like, "Wow, I'm totally not
> worthy. I need to get out of programming now, because I'm never going to be
> able to compete with this." So they just basically demoralized me into
> becoming a manager for a few years.

> Around 1994, James Schmalz had written this 3D texture-mapping code, and I
> was starting to think, "Hmm, maybe that's not so hard." So I started reading
> up on references there and experimenting with it, and it turns out that,
> yeah, it's just another piece of code that you can learn how to create.

[http://www.gamasutra.com/view/feature/4035/from_the_past_to_...](http://www.gamasutra.com/view/feature/4035/from_the_past_to_the_future_tim_.php?print=1)

~~~
munchbunny
Yup, in hindsight it's interesting because the key innovation was realizing
that real-time 3D was possible.

The algorithms themselves (like 3D texture-mapping) are college third year
problem set level difficulty to actually implement, but having the curiosity,
courage, and ambition to be the first to do it real-time is huge!

The algorithms used in today's 3-d game engines are definitely more complex
than something I'd expect a college student to do, but the state of the art
has also progressed substantially since the 90's.

------
lentil_soup
I'm one of the developers of CryEngine, so if there's any questions, we are
watching :)

~~~
virtualized
Did you lose the source code at some point? Because it looks like the output
of a decompiler.

~~~
lentil_soup
Haha, definitely not. Which part looks like that?

------
aavotins
What caught my eye immediately is their licence agreement that prohibits using
the engine to develop, quoting "Serious games". That's a rather vague and
broad statement, what's a serious game?

~~~
vertex-four
1.10. “Serious Games”, i.e. ‘games’ which are not developed for the sole
purpose of entertainment but for purposes training, simulation, science,
architecture etc.

~~~
ominous
How is 'purpose' a legal term? What is the purpose of a game? To milk money
from fans? To obey to some company's internal schedule? To entertain.....
review sites? To entertain me? To showcase technology? To insert subliminal
messages and DRM? All of the above? None?

What was the purpose of tamagotchis?

We may never know.

~~~
wyldfire
From what I've seen, courts are frequently asked to answer questions just like
this one. They do not seem to be as troubled by slippery slopes because it's
their job to decide where the line is.

If you're a student using CryEngine you're probably not worth suing for
copyright infringement (at worst a C&D maybe). If you're a corporate entity
who is distributing a game which licenses CryEngine, you certainly may be
worth suing for infringement.

~~~
sillysaurus3
Which subsection restricts a corporate entity from distributing a game built
on CryEngine?

There are restrictions on Serious Games, but amusingly a Serious Game isn't a
game.

~~~
DigitalJack
I disagree, re: serious game. It's why we have the term gamification. Taking
something mundane and making it, for my lack of a better term, gamey.

I'm thinking of things like Starfighters.

------
ralmidani
I really wish Epic and/or CryTek would release their engines under a strong
copyleft license such as AGPL, with the option to purchase a proprietary
license for developers who do not want to release their games as free
software. This would allow developers of free (as in freedom) games to use the
engine while also allowing the company behind the engine to make money.

~~~
SXX
That would be great, but both Epic and Crytek have no reason to do that.
Releasing under copyleft would mean there will be forks with changes they
can't use for their proprietary branch.

They of course have no reason to use permissive licensing too since that would
mean someone else can make money off it.

~~~
mappu
The x264 library is GPL (i.e. not LGPL). To use it in a closed-source product
you can pay for an interesting kind of commercial license, the terms of which
are you /must/ submit your changes upstream (privately). The upstream can
choose to accept anything that's possibly useful, and will reject anything
that was application-specific.

~~~
SXX
I have no idea if this business model work for x264, but I sure it's work for
Qt and few other open projects.

Unfortunately companies that developing game engines not going to benefit from
copyleft licensing since there is no demand for GPL from real game developers.
After all there is very few open source games around and only bunch of them
aren't clone of something else. Probably none of these projects ever going to
need anything as complex as CryEngine: there is enough of good open source
engines for indie games.

So if they release engine as GPL they simply won't get any more developers in
community. At best there will be few incompatible forks made by developers who
only want to release changes under GPL.

PS: So just keep in mind that in case of CryEngine "source available" offer
appear because it's only way to compete with other commercial engines and make
money. They intentionaly keep it proprietary instead of going open source
since it's better for their business.

------
chippy
This is quite powerful for some: [https://github.com/CRYTEK-
CRYENGINE/CRYENGINE/blob/release/E...](https://github.com/CRYTEK-
CRYENGINE/CRYENGINE/blob/release/Editor/Python/Lib/antigravity.py)

~~~
ekimekim
Looks like they've included the entire python stdlib, which that file is part
of.

~~~
kevinmgranger
But it also looks like they forgot to include the license, which is required:

[https://wiki.python.org/moin/PythonSoftwareFoundationLicense...](https://wiki.python.org/moin/PythonSoftwareFoundationLicenseFaq#If_I_bundle_Python_with_my_application.2C_what_do_I_need_to_include_in_my_software_and.2For_printed_documentation.3F)

(I Am Not A Lawyer, and all that.)

------
yxlx
Doesn't have issue tracker so can't ask them directly. Hoping they will see it
here.

I think that instead of just linking to the license, they should include a
copy of it in the root of the repository and refer to that. It is the proper
way to do it.

~~~
lentil_soup
Just sent this comment to the right people, thanks! :)

~~~
yxlx
Thank you too :)

------
sspiff
Ah man, I was curious to take a look at the early development history of this,
but seems like they didn't push the full history of the engine :(

------
arca_vorago
It's been about a year since I tried cryengine last, but I have experienced
nothing but pain with it, functionality wise, not to mention the lack of dev
response to the users and the other drama surrounding the company behind it, I
am going to continue to steer clear of it, especially with such restrictive
terms.

To me, this is a halfhearted attempt to catch up with Epic and Unreal Engine
4, which has really shown the market how to do things right. I actually look
forward to engine updates with UE4, not to mention the increasingly better
marketplace content. Also, I am hoping to eventually move over to devving
completely on linux...

unity and CryEngine are feeling the hurt, ans struggling to respond.

~~~
rurban
> To me, this is a halfhearted attempt to catch up with Epic and Unreal Engine
> 4

I do rather think it's a last desperate attempt to get it out before crytek is
going bankrupt.

------
Negative1
Unreal makes you 'attach' your account to their repo so they know who has had
access to the source code. I'm surprised CryEngine just releases it in its
entirety without any such 'protections'.

The coding style is very Microsoft-like, which is I suppose not a big surprise
given it's DirectX roots. 8-space tabs seems to be the convention (ugh). They
use XML for their readable format (which explains a little their slow load
times).

The code itself is not very well documented but relatively clear to
understand. Overall not a bad engine to learn a few things from but if you're
new to Game Engines a lot of stuff will probably seem very complex (check out
BreakableManager.cpp).

It's no Quake 3 in elegance but it's got a lot of advanced functionality
(especially in the editor). Overall, it's pretty awesome that they released
this. Its a huge gift to everyone that is curious what a world class game
engine that has shipped a ton of AAA games looks like.

~~~
SXX
> The coding style is very Microsoft-like, which is I suppose not a big
> surprise given it's DirectX roots.

Just in case first CryEngine and early versions of CryEngine 2 had OpenGL
renderers, but code style was pretty much the same.

------
danra
What do the !XT, !B, !U etc. mean in the commit messages?

~~~
lentil_soup
Internal codes to know what the check in is about: bug, feature, update, etc.

------
Yuioup
So .. why would anybody care about Amazon's Lumberyard now that this exists?

~~~
scrollaway
No serious game developer should care about Amazon Lumberyard in the first
place, other than informationally.

Lumberyard is an immense lock in to the amazon stack with a lot of small
print, a huge risk if you believe your game to be worth anything.

~~~
chme
Apparently developers of serious games shouldn't care about cryengine eighter.
;)

~~~
scrollaway
What are you talking about?

CryEngine has (had?) fairly bad licensing terms overall but they're working on
them (this OSS strategy is likely part of that) and they are _nothing_ like
the Lumberyard terms which essentially buy out your soul.

> _57.4 Operating Restrictions. Without our prior written consent, (a) the
> Lumberyard Materials (including any permitted modifications and derivatives)
> may only be run on computer equipment owned and operated by you or your End
> Users, or on AWS Services, and may not be run on any Alternate Web Service
> and (b) your Lumberyard Project may not read data from or write data to any
> Alternate Web Service._

~~~
chme
I am talking about "serious games", because you aren't allow to develop them
professionally with cryengine without written consent. It was a word play to
your "serious game developer".

~~~
scrollaway
Haha woops, completely missed that.

------
jdennaho
2.4. Restrictions on Use: Crytek reserves all rights not expressively granted
in this Agreement. Without limitation, Licensee shall not:

distribute, sublicense or exploit in any other form: the CryEngine (except for
the Redistributables), e.g. as a stand-alone development engine; the CryEngine
Documentation; the CryEngine Tools; use the CryEngine for the development of
any product other than Games, including without limitation: military projects
gambling; simulation (technical, scientific, other); science; architecture;
pornography; Serious Games.

Serious Games? did lawyers actually even read this?

~~~
mhink
A cursory Wikipedia search would yield an explanation:

"A serious game or applied game is a game designed for a primary purpose other
than pure entertainment. The 'serious' adjective is generally prepended to
refer to products used by industries like defense, education, scientific
exploration, health care, emergency management, city planning, engineering,
and politics."

------
greenspot
What I like and what I'd like to understand better from a price economics view
is their "Pay what you want" model; on the following link you see the page
where the user can decide which amount he likes to pay (€0, €10, €25, ...):

[https://www.cryengine.com/get-cryengine](https://www.cryengine.com/get-
cryengine)

I am just wondering how the distribution is, so how many pay 0, how many 10
etc.?

Could imagine that this pricing could lead to higher total revenues than the
classical three-prices-page.

------
_kst_
It would be nice if the README mentioned what CryEngine is.

(By visiting [https://www.cryengine.com/](https://www.cryengine.com/), I found
out that it's a game development platform.)

------
Aoyagi
Hasn't that been there for quite a while?

~~~
lentil_soup
For the past couple of months you could get it from the website as a .zip
file, but now it's source controlled properly in GitHub and connected
internally to Perforce.

~~~
Aoyagi
I see, thanks for the clarification.

------
gravypod
It would be great if the great hobbyist talent out there can also push to
further optimize the CryEngine. From what I've experienced, the engine
performs well, you just need to put a lot of hardware behind it.

------
jordigh
Wow, that's quite the restrictive license they got out there. Just about the
only thing that's allowed is looking at the source code. You can't modify or
redistribute, definitely not sell, and there are tons of restrictions on how
to use it:

[https://www.cryengine.com/ce-terms](https://www.cryengine.com/ce-terms)

~~~
detaro
Modify you can:

 _2.1. Grant: Subject to strict and continuous compliance with the
restrictions of this Agreement Crytek grants to Licensee a non-exclusive, non-
transferable, non-assignable, non-sublicensable, limited license (the
“License”) only:

[...]

2.1.2. to develop, maintain, extend and/or enhance CryEngine pursuant to the
CryEngine Documentation;_

~~~
jordigh
Yeah, that's a big restriction on modification. You can only modify it in the
ways that they document that you can modify it?

~~~
detaro
Hm, you are right, I didn't read that right the first time round. Really
depends on what that documentation looks like I guess.

------
googletazer
My 2c, but its too little too late. Unreal and Unity are the big boys fighting
for game developers, especially indie game developers.

------
anqurvanillapy
It's like the release of the source code of Doom and Duke Nukem 3D. We're
getting old.

------
ionwake
Does anyone how the complexity of setting up a multiplayer session stacks up
against unity?

------
cloudjacker
This is the kind of thing you git clone just in case it winds up being an
accident.

------
cm3
Is it purely header files and this is commonplace at game studios that use
C++?

Edit: What I mean is that the implementation of C++ classes seems to be in
header files and I'm wondering if this is a common way to do things at game
studios.

Found cpp files, but it's interesting that so much of the class
implementations are directly in the headers.

~~~
lentil_soup
It's the full source code, so headers and code

~~~
mijoharas
Could you comment on why there are lots of (non-templated) function
definitions in the headers? Looking at it, it doesn't actually look like there
is that much, from the two random files I opened. In the first random file I
opened[0] I didn't really understand why some of the functions (see link) were
defined in the header.

In another file[1] it seemed to make more sense (getters and setters, along
with a smallish class where I guess you didn't want to bother making a new
file).

[EDIT] Could I also ask why you have defined some very large classes entirely
in the cpp files[2]

Also, thanks for this, very interesting to read the source for other large
projects.

[0] [https://github.com/CRYTEK-
CRYENGINE/CRYENGINE/blob/63418e7c9...](https://github.com/CRYTEK-
CRYENGINE/CRYENGINE/blob/63418e7c9e998272ba79c4a6693f61c382f88e15/Code/CryEngine/Cry3DEngine/3DEngineMemory.h#L53)

[1] [https://github.com/CRYTEK-
CRYENGINE/CRYENGINE/blob/63418e7c9...](https://github.com/CRYTEK-
CRYENGINE/CRYENGINE/blob/63418e7c9e998272ba79c4a6693f61c382f88e15/Code/CryEngine/Cry3DEngine/3dEngine.h)

[2] [https://github.com/CRYTEK-
CRYENGINE/CRYENGINE/blob/63418e7c9...](https://github.com/CRYTEK-
CRYENGINE/CRYENGINE/blob/63418e7c9e998272ba79c4a6693f61c382f88e15/Code/CryEngine/Cry3DEngine/3DEngineRender.cpp#L71)

~~~
munchbunny
There are a few reasons you would do this in CPP, though I'm not sure whether
they apply to this case.

You might put function definitions in headers to (1) avoid linking a library
(2) explicitly declare a function as inline, maybe (3) it's simple enough that
you don't lose readability by inlining it.

The one about putting large classes entirely in CPP files: I wouldn't do it
this way for readability reasons, but putting it in the CPP file directly does
restrict anybody else from using what is supposed to be a one-off helper
class. I think that's the intent here.

------
optforfon
This is very hearsay-ish, but I have a friend of a friend who had to work with
the CryEngine (I think it was for one of those Sonic games) and it was
described as so incredibly buggy and you have to debug it constantly.

Maybe this is their attempt to have the community fix it for them =)

------
shmerl
Nice. I hope Vulkan support will arrive soon too.

------
ddlatham
I wish the README said what CryEngine is. What is CryEngine?

~~~
jtuente
I wish people didn't need hand-holding to tell them where to look for answers,
but then lmgtfy.com became a prominent linking tool.

~~~
ddlatham
Thanks for the reply. I certainly know where I can get such information, but I
think a project's README is a great place to have at least a single sentence
explaining what the project is. Moreover, I suspected other HN readers may
also not know what it is offhand and would find a quick summary in a comment
here (such as the other reply above) useful so that each person doesn't need
to perform the extra step to Google it.

