Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

17571 Excellent

About SeanMiddleditch

  • Rank

Personal Information


  • Twitter
  • Github

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. SeanMiddleditch

    Getter + dirty flag + "mutable"

    My general take on this is that such cases are softly violating single-responsibility and are code smells. 20+ years of coding and I've legit needed mutable maybe 3 times, I felt "dirty" about each of them, and ultimately all the cases I can remember were later removed during refactoring that left the code smaller and faster. I look at it like this: You have an object whose job is to receive and accumulate mutations. You have an object whose job is to provide the post-processed aggregate of those mutations. You have not yet illustrated that these must be the _same_ object. I don't know your use case so maybe they do need to be, but I'd be willing to bet that the code can be easily restructured to avoid it. Such caching mechanisms are necessary when you have an unpredictable pattern of mutation and read-back. That honestly just shouldn't be something you need all that often in well-structured and efficient software. Execute all your mutations in one pass. Transform the data into its efficient-for-use format. Then execute the passes that require that computed state. Look at it as a pipeline of data transformations. Graphics, physics, AI, all of it can be written that way for pretty much any game from Tetris to Destiny. When a caching layer really is needed (e.g. in front of IO) then build the cache as a second layer (a separate object). In place of a dirty flag, revision numbers/counters work a lot better here too, in particular because you then no longer need to mutate a dirty flag back to a clean state; your cache can just compare its last revision number with the source's current revision to know if it should update and never needs to modify the source in any way.
  2. No, it isn't. Purely for legal liability reasons, game companies do not take solicitations from third parties on game ideas. It opens them up to cases were you propose a game they're not interested in right now, then some years later long after forgetting about you someone else proposes something vaguely similar and they start it up, and then you sue them for stealing your idea. Tossing your idea directly into the shredder without even glancing at the title is _by far_ the smartest thing for them to do. Let's not also forget the company's employees' own creativity. Why would anyone want to sign up to work on _your_ idea instead of working on _their own_ idea? Same applies to a large company like Ubisoft; why would they work with an unproven and unknown outside party instead of greenlighting one of the countless game ideas their own employees are kicking around by the thousands? That said, it is entirely possible to be approached by such a company if you make a prototype that's widely known and received. It was common some years back for companies to approach students in competitions like IGF or IGC to hire the team to remake the game as a commercial project. The most famous example of that is Valve's Portal ("inspired" from the student game Narbacular Drop). The important bit is that the students didn't approach Value, but rather Valve approached the students, after they already put a solid year+ of very hard work into a competition-grade student game and demonstrated first-hand that their ideas were actually original and clever, that the core concept actually worked as a game, and that the students could actually do meaningful work coding and designing the game.
  3. SeanMiddleditch

    Devide a scene to increase fps.

    Someone else mentioned the word "culling" which is a key part of the equation here. This is related to those for loops. If 15,000 objects aren't on your screen, there's no need to loop over them when drawing. You already have a quad tree for physics so you've got the basics of the solution in place already: use a scene partitioning system to efficiently find the subset of objects that are actually visible. If 6 sprites are visible and 15,000 are not, your rendering code should only even try to draw those 6 sprites and entirely ignore the other 15,000. A good scene graph (or even just a quad-tree) helps here a massive amount. You can hypothetically reduce your O(N) rendering to O(log(N)) or less which is a huge win. One of your for loops then basically goes away. You never need to iterate over the static objects. Never. Both graphics and physics should be using an efficient graph of some kind to find relevant objects. (Note that physics and graphics might use _different_ graphs, because what makes the most sense for physics isn't necessarily true for graphics.) You can then also heavily reduce the load on your dynamic objects for loop. After all, collision detection is already using an efficient data structure and you'll be changing your graphics to also use a tree of some kind, so the only work for dynamic objects that remains is to apply velocity. Luckily, that work only needs to be done on objects that _have_ a non-zero velocity. You can thus split your dynamic objects into two sets: active and inactive objects. The active objects are the ones that are currently moving. After that split, you might notice that there's no longer any practical difference between static and dynamic objects, so you can perhaps remove that entire concept from the code. Objects with velocity (or some other forces) are put into the active set and are removed from the active set when they stop moving. The physics code need only loop over the active objects to apply velocity and forces. The collision system uses an efficient graph. Rendering uses an efficient graph. Unless you (foolishly) make all 15,000 objects active at the same time, you never need to loop over all your objects even once, much less twice. The next big step then is the batching improvements others have recommended. The third big step I'd recommend is to use an accelerator like PyPy or whatever's in vogue today. Remember that even the simplest operation like adding two small integers should just be a single ADD instruction on the CPU, but in plain ol' CPython that same operation can take hundreds of CPU instructions, branches, memory accesses, and so on. Python does not translate to CPU code very well and requires a sophisticated JIT engine to do even marginally well in terms of performance, and Python does not include such a JIT engine out of the box like JavaScript engines do, so you have to use an add-on/replacement like PyPy.
  4. SeanMiddleditch

    SpeedTree 8 for Lumberyard Now Available

    SpeedTree. Lumberyard. Heh.
  5.   Jeebs. We've been complaining about a mere 20 minute full rebuild time and are getting ready to throw engineering resources at dropping it back closer to 5 minutes, and I'd still consider 5 minutes to be excessive. :)
  6. SeanMiddleditch

    [Enet] Multiple Client connections

    I don't know ENet, but looking over the docs and your code quickly, I don't see an immediate problem, but I'm lacking some context. You _should_ be receiving a single CONNECT message per client connection, and each one should have a unique instance of ENetPeer which you can freely modify and store data upon as in your code. You should not be receiving a DISCONNECT message between the first and second client connection if you're expecting them both to be active; are you? Are the addresses of your peer pointers difference for each CONNECT message or is the same peer being recycled? Highly unrelated note:     // Bind the server to port 1234     address.port = 8484; this is a perfect example of why comments should not just repeat what the code is (supposedly) doing. :)
  7.   Valgrind is a poor fit for games, unfortunately. Its biggest problem is that it effectively runs as a full emulator and will make a game run 100x slower; if just hooking allocations is too slow, that's certainly not possible. Valgrind also isn't compatible with Windows which is a deal breaker for most game developers. There are toolkits that do similar things which manage to be both far faster and Windows-compatible, though perhaps without quite as much accuracy.   Highly recommended. One of our engineers just hooked this up to our (big AAA) game recently and we've been impressed. A custom tool like Hodgman recommended can still have a lot of benefits that you won't get with MTuner but a custom tool would probably be overkill for the OP. Someone needs to write one of these as open source. It's an easy enough problem to tackle for someone with the time and experience. :)
  8. If hooking allocation functions is causing the game to run that slowly, that's probably an indication that you're doing _waaaaay_ too much allocation during the game loop. Which in turn probably causes fragmentation. Also means you've got that much more room to mess up and leak (though with modern C++ programming, that should be rare). It also could mean that fragmentation is leading to allocation failure. An idealized game preallocates as much memory as it needs before entering a level or whatnot and never allocates again. Larger open world games can get by with good object pools and paging techniques, though this takes a lot of effort and discipline. If your third party libraries are the source of allocations, you have some mitigations. Most third-party libraries made for games allow hooking the library's allocation routines. You could use those hooks to pass the libraries straight to the fast allocator and then only override the allocator for your game code, and verify whether your own code is leaking. Alternatively, you can enable the leak detector individually for each library to track down the culprit. If it's just fragmentation, hooking the offending library to use its own small block pool allocator may be the solution.
  9. That isn't the real problem with them. The main problem is that they just don't work the way most people think they do, and it's fairly trivial to break them in larger build systems. And part of _that_ problem is that pragma once is not well-defined. Namely, how does the compiler decide that a header has already been included? Is it the file's inode? Relative path name? Absolute path name (including symlinks? multiple mount points? etc.) ? What about a file that is accessed through two separate paths that go through two separate virtual filesystems (like an NFS mount to the localhost and the direct local path? yes, there are systems setup like this, and can be relevant to games on Linux-based CI systems). This also comes up on some weirder systems (not relevant to games) that don't have directory structures similar to the POSIX/Win32 model. Basically, it's impossible to make pragma once work reliably the way people expect. There simple isn't a way to uniquely identify a file across all possible file systems, platforms, and weird things some platforms can do with reparse or mount points or network filesystems and so on. The compiler differences do come up. For instance, porting code between GCC and MSVC when using precompiled headers on both can be a little tricky specifically because of the different rules each have surrounding #pragma once. Those differing rules also make it impossible to standardize, since if it were then one or the other would be required to change behavior and break existing code.   #pragma once will never be standardized since it is inherently broken as described above. The #once proposal is basically just a syntactic shortcut to include guards: the #once syntax requires an additional token (just like an include guard) to identify the file which is intended to be unique (though it could be used to ensure that only one of a particular set of files is included by sharing the identifier between them). "#once foo" essentially just wraps the file contents in "#ifndef FOO #define FOO #endif". And even that's super unlikely, because Modules will kind of make traditional headers obsolete anyway.   ... all that said, I just use #pragma once myself. :p
  10. SeanMiddleditch

    how to do a building timer?

    I wouldn't necessarily do a _timer_ at all. A timer implies some kind of eventual state change. It implies an eventual computation and an eventual event. If you start building, you must send an event to all players, and then upon completion, send a second. And know when the completion happens, efficiently. That's a lot of stuff. Instead, just store the building as state with its initial build time and its expected completion time. Send both to the clients in a single event. Now all clients know when the building will be completed and can update themselves accordingly with no further involvement from the server. For big Web-scale MMO things, you want to avoid every possible computation you can. Work in the minimal state changes possible. Create the building with all state it needs to know its current and eventual building state. If something changes the expected state (additional resources put into construction, for example) then update the state and expected completion and send that event to all clients (they'll need an event anyway to make the proper UI changes and the like). Minimal effort/data/events.
  11.   It's kind of a weird beast in terms of type system classification. If you very strongly prefer static typing as all just and goodly folk do, look at the compiler options that enforce all the extra rules. Out of the box, TS is geared for incrementally adding typing to existing JS codebases which isn't necessarily the best default for a brand new project that wants to be good about typing right out of the gate.
  12. There are a few questions to answer to guide you on the righ tpath here: (1) what languages do you know and are you comfortable with? what about the rest of your team? (2) what language and technology is your game written in? do you need to share code between the game and tools? (3) do you _need_ multi-platform capabilities? that vast, vast, VAST majority of game development is done on Windows, even for games that are released on other platforms. that's not only because of the game tools, but also tools like ZBrush, Maya, Photoshop, and a myriad of other game content creation tools that you need to actually make a game are either Windows-only or Windows/macOS-only. Linux is so far at the bottom of the barrel as to be irrelevant in terms of content development platforms, and making your tools run on Linux is only going to solve a teensy tiny fraction of the problems with using Linux for content development. Note that C# and C++ both have cross-platform GUIs that support macOS and Linux if you do want it. A lot of companies choose C# for everything that isn't the core engine. A lot of companies also stick to C++ and use Qt for tighter integration. Some even use Python for various things, particularly since modern Maya scripting and plugins use Python heavily. Some related points:     Use Typescript if you go this route. I'll go so far as to make that a blanket statement: programming in plain ol' JavaScript _ever again_ is for suckers. Don't be a sucker. :) A very related alternative to Electron, btw, would be to use Chromium Embedded Framework. Or whatever Qt's current favored incarnation of its HTML5 widget is. Write the core app/engine in C++ and then use HTML5/TypeScript for all the editor UI and editor logic.     You could always make them a separate free download, assuming this is a game. The vast majority of players will never use the tools, so even if the tools are small, your game itself will be "bloated" if you distribute them to everyone. :P     It absolutely supports macOS. :)
  13. SeanMiddleditch

    Looking for game engine / game lib

    http://www.cocos2d-x.org/ -- focused on 2D, but fully free, low-level library approach, widely used https://godotengine.org/ -- free 3D engine, comparable to what you should expect from a free engine https://aws.amazon.com/lumberyard/ -- basically Crytek, not technically "free" but you don't have to pay anything https://www.unrealengine.com/what-is-unreal-engine-4 -- ... it's Unreal, not technically "free" but you don't have to pay anything   I don't comprehend your complaints about Unity's licensing. If that's really a problem scratch off the last two above as well. The only way those will be _actual_ licensing costs for you though is if you're one of the 0.0005% of indie game developers who actually make any significant money from your project (and if you magically are one of the Chosen Few that even manages to break even, the cost is very affordable and reasonable).
  14. SeanMiddleditch

    Going to GDC?

    I think this is declining fairly rapidly (the odds of your card just getting a weird look while someone pulls out their phone to enter your info directly or trade via NFC are increasing) but it's definitely still good enough advice for now. I give it to 2020 before cards are a complete relic. :P I might be biased though because my company's cards are garbage solid-black affairs that you can't scribble notes on and I end up using maybe 1 or 2 every GDC. Which reminds me - anyone printing custom cards, always leave the back entirely/mostly plain white. The blank space is as valuable (if not more so) than everything else on it. :)
  15. As others have said. The things to watch out for that GL does differently than D3D are mostly just two things: - the GL NDC has a depth range of -1..+1 rather than 0..+1, so you have to construct your projection matrices accordingly to get full precision. This one is easy to ignore but you shouldn't. - GL has inverted texture coordinates from D3D, requiring textures to either be flipped when loaded or shaders to invert the access. This is the most obvious issue you run into when porting and the internet is filled with questions and answers about it. Hypothetically there may be extensions to correct these issues, though there weren't the last time I subjected myself to OpenGL.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!