Jump to content

  • Log In with Google      Sign In   
  • Create Account

haegarr

Member Since 10 Oct 2005
Offline Last Active Yesterday, 12:44 AM

#5240039 Making my model class Vertex Independent

Posted by haegarr on 13 July 2015 - 03:36 AM


As you can currently see, my model class is dependent on Vertex::Basic32 vertex. How would I go about making this class vertex independent without actually using inheritance and virtual functions?

The only occurrences of Vertex::Basic32 I've seen are in Model::LoadFromFile(…). The responsibility of the Model class (as it looks for me) is to group related graphics resources for the runtime. As such it should not be responsible for how the components come together (may be loaded from mass storage or generated dynamically). It should especially not be burdened to know about assimp. Instead it should have getters and setters for its components and perhaps some validation routines.

 

The task of loading model components should be external to Model, e.g. in a ModelLoader class. This one (or one of its derived classes) then knows how Model components are represented within assimp, and is able to do the conversion into the internal data format.

 

It would be okay for ModelLoader to have virtual functions, because loading is a relative slow process anyway so the one virtual call would not be noticed. Furthermore, loading happens very seldom.

 

 

BTW: Please avoid linking to temporary external file sources as long as the files are relatively small, but embed them with the source tags into the post. On one hand that lowers the barrier for us to look at your problem, and on the other hand it will not drive the thread needless because of the disappearance of the external files one day.




#5240018 Why is my constructor/Renderer class being called twice?

Posted by haegarr on 13 July 2015 - 12:51 AM

In such a case: Set a breakpoint and run the program in debug mode. When the debugger stops, then look at the object-id of "this" and at the call stack. When after continuing the debugger stops a second time, look again at the object-id and compare it with the one before, and again look at the call stack. Use the call stacks to realize which functions have caused the invocations.




#5239699 54x50 tiles map searching for neighbours - takes extremely long

Posted by haegarr on 11 July 2015 - 03:08 AM

1.) An hour seems me too long for that piece of software. Do you have measured it with or without all those cout invocations? Printing so many lines to the console typically eats much performance.

 

2.) Of which type is m_walkables? Is it necessary to iterate it as done? Using a naturally indexable container would roughly half the amount of visits.

 

3.) How is getCost(…) implemented?

 

4.) How much copying is done inside setNeighbours(…)?

 

 

Although not knowing the exact situation, it seems me that you use the wrong approach. An indexed storage of the tiles would make this problem be much more performant. Perhaps you could explain the situation, so we can find a suitable solution.




#5239441 free private SVN with biggest disk space?

Posted by haegarr on 10 July 2015 - 02:25 AM


[edit] as pointed out below this can be as expensive as renting a server/service -- A 250W PC * 0.15c/kWh * 24hrs * 30days = ~$27/month -- so check your utility rates and look into low-power PCs to use as the server

For comparison: I'm running an old Core2 Duo linux based server at 65W and a new i5 QNAP NAS at 50W (measured during idle but rotating HDDs), each one with 4 HDDs in RAID 1+0. When disks get parked during low access frequency times, the values drop accordingly.




#5239154 New take on Conversation in Video Games

Posted by haegarr on 09 July 2015 - 02:01 AM

Well, what you describe is not really new. But it is nice to see another soul that's thinking how to replace the simplistic dialog tree mechanics. So don't get me wrong because most of the following sounds like critique. smile.png

 

a) There are more dialog mechanics besides the both you mentioned. The group of "branching dialogs" consists of the dialog tree but also of the "hub and spoke" variant; there are even planner like mechanics. See e.g. this and this article on Gamasutra.

 

b) A FSM is by definition a collection of states with conditional directed transition in-between. In an FSM just 1 state is active (as long as you do not mean HFSM). Implementing an FSM with those 6 degrees of freedom would practically become impossible very fast. What you describe seems me to be something different, more like some kind of decision tree. 

 

c) A "state" you've forgotten is the need / goal of the speaker. This is very important, because a person is willing to ignore mood and whatnot in case that it helps to yield a goal. It must even be possible to lie. All this may be important to drive the story, too.

 

d) Having the possibility to change the topic is nice not only for the player but also for the NPC, because it allows an NPC to drive the dialog into a direction that matches the story. But care must be taken that an NPC does not rapidly hop from one topic to another. When the player des so then the the opponent should probably get angry (i.e. changing its mood). See e.g. Emily Short's articles about that problem. (BTW: Emily has many interesting stuff to say, although she's more related with IF instead of video games.)

 

e) Besides the mechanics, also the UI plays a big role. The player need to recognize whether a sentence may endear or insult the opponent. Remember that not all players may understand the language in which they are playing good enough to recognize nuances. It is also nicer for the player not to need reading 4 times 5 lines of text just to decide which answer to give. There is an article about dialog UIs on Gamasutra (unfortunately I do not find it ATM). The more influence a dialog system has, the more important is its flawless controlling.

 

f) Regarding the effect of stats on dialogs and the possibility to change stats due to dialog, you may want to read the PDF about SimDialog available here.




#5238941 checking if resource has changed

Posted by haegarr on 08 July 2015 - 03:40 AM

The OP asks for "dirty resources to be saved or discarded" and a belonging user decision. This is a different problem than those of hot swapping of updated resources. The former one means to update files from memory, and the latter means to update memory from files.

 


In my engine code I check if resources* have changed so I can ask the user if they want to save or discard the changes in various places. [...]

I'm not sure why this happens "in my engine", assuming that "engine" means a game engine in the meaning of a game runtime. Resource changes and save requests belong to the editor. Integration of the editor with the game runtime like in "editor in game" is IMO not a clean way since it burdens the runtime code and hence makes it maintenance more difficult.

 


[…] but before I dive in and change a bunch of stuff I though I would ask others how they handle the "dirty" problem.

 

Some possibilities and thoughts:

 

Command style editing

 

Resource changes and save requests belong to the editor. Making changes undone should also be possible in such an environment. Instead of using a single flag, a counter of dos / redos (increments) and undos (decrements) targeting the respective resource can be used to track dirtiness. A saving would reset the counter to 0, and any value different from 0 (notice that this includes negative values, possible due to undos after a saving) denotes dirtiness.

 

This way does not counteract issue #2 as mentioned in the OP, but using OOP style patterns like the Command may support to avoid that kind of bug.

 

It also does not totally counteract issue #1, since changes back to a previous state are only considered if performed as an undo. However you need to notice that some kinds of change-back (like translation when using floating point numbers) may yield in a visually identical resource although also the message digest of its serializations will differs.

 

 

What You Made Is What You Want (perhaps somewhat controversial)

 

Notice that from a users point of view (and ignore the fact that we, as users, are familiar with the concept of saving, because this is just due to history) the dual state of a software object, namely its state as file and its state in memory, is a suffering. The whole load/save stuff exists due to technological reasons only, not because it is the optimal workflow. Ideally you could stop working with a software, and when continuing it the state is as you left it before. This obviously must include the possibility to roll back to previous states. However, the consequence is that nothing like a dirty state exists anymore; at any moment the current state is assumed to be what the user wants.

 

 

Message digests

 

When checking the message digest of the in-memory representation with what is stored in a file, it would obviously be killing the performance if every digest is computed on the fly. Instead, if possible, the digests of files should be computed once and stored along the file. This may even be done in a kind of catalog file that's used to collect the names and digests of all files in a directory that are used in the project (similar to archives). 




#5238628 Why use texture splatting?

Posted by haegarr on 06 July 2015 - 10:09 AM


Is there something I am missing?

The RGB textures are of fine detail, repeating many times over the terrain. The blend texture(s) are coarser, covering a large area of the terrain. I.e. you do not have blend control over each individual pixel but the splats.




#5237458 Memory management patterns in C++

Posted by haegarr on 29 June 2015 - 04:18 AM


I don't think it is possible in modern games to just have a single memory management scheme. You need multiple and use each in the right way.

Seconded. Hence ...

 


How have you solved this problem in your projects?

… situation dependent. Here are some examples that do not rely on reference counting:

 

Regarding the ownership, resources are owned by the respective resource management systems, while game object components are owned by the respective component service systems. Scratch memory is owned, of course, by the instance that works with it. Sometimes there is a clear hierarchy; e.g. network messages are owned by a transaction, which themselves are owned by a connection. And so on.

 

Regarding lifetime, resources are typically bound to the lifetime of higher concepts. E.g. resources for the GUI or the player avatar are bound to the lifetime of the game itself, while other resources may be bound to the lifetime of the level or a region. Game objects are created / destroyed at a defined step in the game loop. Each component service system is responsible to deal with destroying game object components of the managed types and in a way that is suitable for the service system. Network messages are recycled in the well known pool memory allocation scheme.

 

Addressing game object components across service systems is based on handles instead of pointers, but handles can be resolved to pointers when necessary. Such pointers are guaranteed to be valid only for a single run through the game loop. Resources are addressed similarly.




#5237246 A more simplistic way for this?

Posted by haegarr on 28 June 2015 - 06:45 AM


Im just wondering what sort of trig formula is this
dx /= c;
dy /= c;

change of x = change of x/ hypotenuse?

Together with the computation of c it is a standard operation in vector algebra called "normalization", in this case using the so-called Euclidean norm or 2-norm. The Euclidean norm of a vector denotes the length of the vector in Euclidean space. Then dividing the difference vector (which is given by the 2 differences as (dx dy) ) by its own length results in a vector that points in the same direction as the original vector but has a length of 1 (i.e. it has unit length); thus it is called "normalization". Hence the resulting endpoint lies somewhere on the unit circle, i.e. the circle with radius 1. So the normalization step is equivalent to

   dx := cos( angle ) = r * cos( a ) where r==1

   dy := sin( angle ) = r * sin( a ) where r==1

but where the angle a is anything in [0,2pi] (as opposed of what you compute as angle in the OP).



#5237229 A more simplistic way for this?

Posted by haegarr on 28 June 2015 - 04:06 AM


Im just wondering if you guys implement the same functionality with minimal ifs. and if so how did you do it?

 

1.) The if clauses are not complete, because none of the conditions checks for dx==0 or dy==0. However probable such a case is, it does cost nothing to check it but will fail if not doing so.

 

2.) All the if clauses would not be needed if the atan2 function would be used. As you already have noticed, there is a meaning with the atan2 function that makes it superior (in many cases) compared to the atan function.

 

3.) The entire approach can be replaced by using vector math. If I understand the code snippet correctly then something along

                // elements of difference vector
                dx = mousex - sprite.originalPosition.X;
                dy = mousey - sprite.originalPosition.Y;

                // length of difference vector
                c = (float)Math.Sqrt(dx*dx + dy*dy);
               
                if (c > radius)
                {
                        // direction vector (normalized difference vector)
                        dx /= c;
                        dy /= c;

                        // adding scaled direction vector to position
                        mousex = (float)sprite.originalPosition.X + (radius * dx);
                        mousey = (float)sprite.originalPosition.Y + (radius * dy);
                }

should do the same thing. (Notice that the above solution assumes that dx, dy, and c are floating point variables.)

 

 

BTW: I'm missing what exactly this has to do with a joystick...




#5236926 -std=c++11 with Xcode 4.6

Posted by haegarr on 26 June 2015 - 08:51 AM

Not sure whether Xcode 4.6 already supports C++11; you should consider to switch to a 5.x version.

 

However, when you open the "Build Settings" for a target, then search for the fields "C++ Language Dialect" and then "C++ Standard Library" and pick the C++11 option that suit your needs. If the options do not provide some "C++11" and/or "GNU++11" stuff, then you need to upgrade Xcode, of course.




#5236885 Dealing with different collision responses in an entity-component system

Posted by haegarr on 26 June 2015 - 01:45 AM

When I once thought about collision in ECS I saw several problems when selecting a collision response: (1) An entity may have more than a single collision volume, (2) the response depends on the types of both participants, and (3) simultaneous collisions involving the same entity have to be handled / resolved in a meaningful manner.

 

For example, in an RPG with a sense system, we want to support damage of course, but perhaps distinguishing different body parts so that the collision volumes for this are more detailed than the "physical" one used to avoid running into a wall. The sense system may introduce different collision volumes for the visual, aural, and olfactory senses, and that for both roles as detector and as stimulus.

 

Well, the conclusion to me was that I moved away from a unified collision system and towards dedicated systems. To serve this, there is also no longer a single unified collision component but components that match the systems, of course. The collision volumes are then parameters to that components, and the components declare the owning entity to participate of the respective systems and also in which role this happens. While all such systems use the same volume intersection services, each one manages the own set of colliders and each one has its own set of rules of how to respond to a detected collision.




#5236402 manging lifetime of textures/buffers etc

Posted by haegarr on 23 June 2015 - 12:48 PM


I would have to somehow know that nothing is using a particual Texture any more and manually call mDevice->DeleteTexture(textureHandle).
So do people implement some form of reference counting inside the Device to count CreateTexure and DeleteTexture on each texture handle? It seems if I'm going to do that I might as well just use a shared_ptr anyway to count it?

Many engines manage memory not in a totally dynamic way. Instead they define memory budgets for particular purposes and they define lifetimes a priory. For example, some assets are loaded at game start and unloaded when the game ends, i.e. they have game lifetime. Level based or region based lifetime are other popular methods. Streaming may also be used in which case buckets of memory are allocated once and then cleared and re-used in dependence on vicinity or whatever. However, the clue is that the lifetime is not measured but prescribed.

 

I do not know what exactly the Molecule Engine does, but the articles and comments in that blog mention such things, too.




#5236273 Landmarks

Posted by haegarr on 23 June 2015 - 01:10 AM

Castle Settings

 

* awesome tapestry

* torture chamber

 

Cavern Settings

 

* abyss

* subsurface flow (short piece of)

* opening in the ceiling where sun / moon light comes in

* lair (e.g. of bats)

* occurrences of natural resources in the walls

 

Sewer Settings

 

* entrances / exits

* catchment basin 

* some kind of machinery (pumping, forwarding)

* any bigger room as opposed to the narrowness of the regular sewers

* (e.g.) rat nest

 




#5235824 Finding near and far plane from projection matrix

Posted by haegarr on 20 June 2015 - 03:58 AM

f - 5 = f / 1.02564

-5 = f / 1.02564 - f

    = f ( 1 / 1.02564 - 1 )

 

f = -5 / ( 1 / 1.02564 - 1 )






PARTNERS