• Content count

  • Joined

  • Last visited

Community Reputation

1561 Excellent

About larspensjo

  • Rank
  1. Problem is not specifically for sorting, but the more general case. I just used sorting as an example.   It may be that it is impossible to formulate general purpose fitness functions for problems that are not numerical in nature, unless using detailed knowledge of the specific problem.   Jeferytitan had some interesting suggestions I can build on. That is, it is easier to define penalties on behavior. 
  2. inheritance tree in one file

    What starts to breakdown? Inheritance? if so what makes you say that?   A typical example could be having a big tree of inheritance, and then you find out you need a new type of object that has the properties of two types of objects already in the tree. Using multiple inheritance for this is generally discouraged. That means a re-organization of the tree is needed. If pressed for time, there is risk this re-organization isn't done, which can lead to ugly dependencies and special work-around that are difficult to maintain and debug.   One design pattern that can help in this situation is the Entity-Component-System.
  3. best way to backup my project

    To add to the answer of ProtectedMode, the use of Git allows you to effectively do "incremental backups". That is, you check-in your changes locally. But now and then you do "git push", which will push all changes to a selected server. This is usually quick, as git will use compression.
  4. Problem: How to make a good fitness function?   Assumptions: There is a specially designed programming language. The program will not directly modify itself, but indirectly through the use of genetic algorithms. Using mutations combined with child generation from random parents. The language is fairly resilient to bit mutations. The merger of two parents will have a high chance of producing a new algorithm that is not completely broken. A problem with using randomly created algorithms, compared to e.g. neural networks, is that these algorithms are unlikely to produce any usable output. At least initially. Designing a fitness function for a numerical output can be easy, which could be a measurement of the distance from the result to the target. But what about a fitness function for a sorting algorithm?   Using a fitness function limited to the outputs 0 and 1 is not good enough. It will almost always produce 0, not providing any help for the genetic algorithms. Given my preconceptions about sorting, I could create a fitness function that gives some score for actually reproducing some input on the output. And gradually increase the score the better the output is ordered.   But there are drawbacks with this kind of fitness functions: It presumes that a certain intermediary result is good, a step on the way to a final solution. But that may prevent the algorithm from finding the non obvious solutions I didn't know about. It requires a lot of effort to formulate. A different function will be needed for different algorithm problems. I am not sure there a solution to this problem. Any feedback or references are welcome!
  5. Events with lambdas

      Did you make that?   It was created by Tim Janik, I just put a copy in Github to make it more accessible to my projects and others that would need it. It is not copyrighted by Tim, but there is a readme that clearly attributes the source to him.
  6. gui/game librarys FOR C++

    For GUI, I recommend libRocket. It is general purpose, independent on other game engines, and can easily be adapted for OpenGL (which is what I did). On the negative side, it takes some effort to interface. On the positive side, it is very efficient and powerful. You will be able to control the GUI with a design similar to html and css.
  7. Events with lambdas

    For an example of a C++ event manager that is type safe, simple to use and very efficient, see SimpleSignal.   As far as I have found, it provides the optimal solution for me.
  8. There is an implementation of 3d Simplex noise at github/ashima/webgl-noise. I was mainly worried about higher performance costs as the 3D noise is more complex than the 2D noise. But it turned out this added a negligible time to the shader.
  9. There is an example of an ECS implementation, which is very efficient. I think it is based on a similar idea as noizex #2, but without a hard 64-bit limitation?   Look at the tutorial on the front page, it is quite easy to follow. It takes away most of the implementation details from the user.
  10. 2D Lighting with Shaders

    The equation you are using, is almost like a filter, where you filter light sources through "rgb".   I think the source of the problem is that the background rgb is white? If so, this part should really reflect more. Is that what you are going to use, or are there going to be other colors?
  11. I am using the uv coordinate as a seed for a 2D simplex noise to create surface effects. If the triangle has the normal pointing at z, then xy can be used as uv coordinates.   However, the triangles have more or less random orientations. I suppose I need a rotation so as to have the normal aligned with e.g. z, then I can again use xy as uv. I have difficulties to find out how to do this rotation.   It may be that the problem can have more than one solution, but I only need one. Is there an efficient algorithm for this?  
  12.   Sorry, I don't have a specific answer to your question. You have the experienced the black screen of death in OpenGL. There are quite a lot of single point of failures when programming OpenGL, and many of them will give you a black screen.   My personal experience is to do as follows: Whenever something works, I check it in to a version control. I make many small check ins, making it easy to back step when something stops working. I make sure every small step still works. This relates not only to OpenGL, of course. Now and then, I grow more confident as I feel I have enough experience. And then I suddenly have to spend a lot of time debugging and try to understand why something was broken.   Otherwise, I would say you are on the right path. That is, you need to create a library/framework for using OpenGL (or use a library from someone else). OpenGL is low level programming, and it has helped me to add some layers above it.
  13. That is a common misconception, which makes it hard to understand. Actually, the camera is stationary! You move the whole world (using the view matrix), and you turn the whole world, to get what you want in front of the camera. Looking at it that way, the transforms are obvious. Well, no, it isn't a "misconception". It is a legitimate view onto the things. It may seem that a view space is something special but it isn't.   * Can a camera be placed in the world like any other object? Yes, it can.   * To what is a camera stationary? It is stationary to ... itself!! But that is true for any object in the scene. If you chose a reference system where you sit down, then it becomes stationary for you.   * What if you have 2 cameras in the world: How could saying that both are stationary is more intuitive?   * Is a light also special / stationary because one transforms into its local space when computing a shadow volume?   * Is an ellipsoidal shape special because, when raytracing it, one transforms into its local space where it becomes a sphere?   * Is the world special because one does collision detection within?   Mathematically there is nothing like a natural break point in the chain of transformations from any local space into the screen space. One chooses the space where a given task is best to be done. For sure, the best space for screen rendering is not the world ;)   The problem with placing the camera in the world is that you don't use the same transformation matrix as when you place any other type of object in the world. So on that regard, it is not just like any kind of object. If you want to move an object to the right in your view, you add a translation to that specific object. If you want to move the camera to the right, you subtract a corresponding translation to every object in the world.   I agree that it is valid to use any reference system (view space, word space, screen space, etc). But you can't use more than one camera. That is, if you have more than one camera, you render them one at a time. E.g. creating stereoscopic views, shadow maps or cube maps.
  14. That is a common misconception, which makes it hard to understand. Actually, the camera is stationary! You move the whole world (using the view matrix), and you turn the whole world, to get what you want in front of the camera. Looking at it that way, the transforms are obvious.   Kind of, if you see the camera as something you place in the world.
  15. OpenGL Using normals with voxels

    An important question: Is this really a problem?   You should wait with this optimization until you find out that it is really an issue. Then, depending on exactly what the issue is, you optimize.   It is not unusual that a change of algorithms can give much better pay-off. For example, improved culling or the use of LOD.