question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Include more helper methods.

See original GitHub issue

Hi,

I always felt that the Xenko engine was a bit lacking when it came some general helper methods. So I started the XenkoToolkit project but I really feel a bunch of these things should be included in-the-box. For example:

  • Find components in entity hierarchies.
  • Transforms using the Entity’s Transform.
  • Transforming things between world and screen space.
  • Calculating rays for doing picking using physics ray cast.
  • Transforming Prefabs when being instantiated.

I am creating this issue more as discussion. I am not super confident in the quality of my code as they have not been thoroughly tested and my math skills are not great. There are probably also a few questionable design decisions. For example, not sure about all the overloads I did either, may have gone a bit overboard. There are quite a few shortcomings as well, i.e. a bunch of the transform extensions throw exceptions if TransformComponent.UseTRS is false (I couldn’t get the math right).

There are a number of things I would do differently if they were included in the engine, i.e. put the Quaterion look at function in the Quaternion struct.

There are somethings I would almost certainly leave out like the material stuff I did. A better option would be to change the ModelComponent and related systems to handle being able to set material properties per ModelComponent.

cheers, dfkeenan

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
profancommented, Apr 19, 2019

Just echoing this, Xenko is missing a lot of stuff that you end up doing all the time (like screen -> world, world -> screen transformations), and writing it all over again for every game or making the engine unnecessarily hard to use for users who aren’t including a certain toolkit 👀

Currently the common advice is just “just get this package of extensions because you’ll need them either way”. So it would be quite nice to have them in core, it would also mean a far easier time for teaching anyone the engine (so smootehr for people like Aggror when making tuts).

2reactions
xen2commented, May 24, 2020

Just my opinion, but I am not a fan of including this specific one in Stride core:

  • It is simply doing game.UpdateTime.Elapsed.TotalSeconds under the hood.
  • I think game.UpdateTime.Elapsed.TotalSeconds is much more explicit (from GetDeltaTime() we don’t know it’s in seconds or milliseconds, is it delta update time or delta draw time, etc.)
  • Usually it’s better to avoid two different API in different locations for the same thing (people will start to get confused when they see a sample with the one they’re not used to, wondering if it’s same thing or not as the other approach). Especially more if it’s just for simple accessors like this.
  • If people really want to use it, they can still use this kind of extension as a nuget package or create their own (that fit exactly their more specific needs) in their project.

However, if the problem is that game.UpdateTime.Elapsed.TotalSeconds is too long/complex (which I can understand), I think that’s the part of the API that we should redesign.

Overall, I was more interested to possibly integrate the functions/extensions doing more complex operations (that can’t be done as oneliners, or need to connect several unrelated API) and that adds real value. Example: https://github.com/dfkeenan/StrideToolkit/blob/master/Source/Toolkit/StrideToolkit/Engine/CameraExtensions.cs (for this one, it might be difficult for users to properly use math libraries on camera properties, so having helpers to do that is useful)

Read more comments on GitHub >

github_iconTop Results From Across the Web

design - Can helper-methods be overused?
Helper methods can make code more reusable by splitting out a piece of logic that might be reused elsewhere. Through these twin lenses,...
Read more >
When to include helper methods in a model (MVC)?
The answer lays in area of responsibility. A model class is responsible for knowing how to add stuff to it, modify stuff in...
Read more >
What exactly is a helper method? (Example)
I have created another Test class and used the HelperMethods.preMr() helper method to prepend "Mr." to the name. I can create more classes...
Read more >
How to Use Rails Helpers (Complete Guide)
A helper is a method that is (mostly) used in your Rails views to share reusable code. Rails comes with a set of...
Read more >
Breaking Down a Problem by Building Helper Methods
As programs become more complex, one lesson that I have learned is that it is important to break a complex problem down into...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found