Jump to content
  • Advertisement
Sign in to follow this  
Tristan Patrick Richter

Game Design Patterns and Programming Methodology

This topic is 583 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have an AbstractActor class with:

 

Vector3 Scale;

Vector3 Position;

Quaternion Orientation;

 

public static void Rotate(Quaterion rotation) { ... }

 

The Heightmap class extends from AbstractActor...but there is a problem. I do not want the Scale of the Heightmap to have a setter (it should always remain Vector3.One), and I do not want the Heightmap to be rotatable. I have solved this by marking both the Scale property and Rotate function as virtual and having them throw a NotSupportedException when called. But now in my Rotate(Quaternion rotation) function, which recursively calls itself on all child AbstractActors, it calls Rotate in the Heightmap class, which throws a NotSupportedException.

 

How would you guys best handle this situation?

 

Share this post


Link to post
Share on other sites
Advertisement
I would probably stop deriving from AbstractActor.

Then determine the minimal set of polymorphic functions you need (if any), and use an interface for those.

Then determine the minimal set of shared data you need (if any), and compose a struct/class of those members into your class instead of deriving. Edited by Nypyren

Share this post


Link to post
Share on other sites
Does Heightmap have to inherit from AbstractActor? That bit sounds a bit weird to me.

If the idea is that everything in the world is an Actor then I would suggest that AbstractActor probably shouldn't have scale and Orientation (and potentially Position) in it to begin with.

Share this post


Link to post
Share on other sites

You will probably create more problems than you solve by making a heightmap be an actor.  It's likely to be a special case in every scenario (collision, rendering, etc.).

Share this post


Link to post
Share on other sites

Becareful about what is what. An actor is typically some sort of object responcible for a logical function and communication between other objects. While a height map has a logical function, it does NOT communicate between actors.

Share this post


Link to post
Share on other sites
The previous posts sum up how to handle it from a pattern/methodology standpoint. But if you want to hack the problem away why not override with an empty method instead of throwing an exception? Assuming heightmap will be a leaf node (cant imagine it would have children you'd want to apply rotation to), it should be fine to let the recursion branch end at it.

Share this post


Link to post
Share on other sites

The Heightmap class extends from AbstractActor

 

why?

 

.but there is a problem. I do not want the Scale of the Heightmap to have a setter (it should always remain Vector3.One), and I do not want the Heightmap to be rotatable.

 

if a heighmap is not an actor with extra stuff, it should not inherit from actor. right?

 

if an actor and a heightmap have common components, they should be composed of those common components, plus their unique components or member vars.    that seems to be the prevailing theory these days.

 

personally, it seems like a pretty good way to organize things.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!