-
Posts
2,953 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by Roland
-
-
-
With my method it runs the same speed no matter what.
Well great then If it works it does. So problem solved
-
Just some free thoughts on this
If you are after most efficiency use either std::vector or simple arrays. Using std::list or std::map is not at all suited for games as iterating over them is quite slow compared to vector
If possible store the objects and not pointers to them in your array in order to get contiguous memory. Iterating over any data in non-contiguous memory imposes a lot of cache misses in general and removes the ability for the compiler and CPU to do effective cache prefetching. This alone can kill performance
When removing from your vector use the 'swap/pop' method. This way you keep your array contiguous
std::swap(entitys[index], entitys());
entitys.pop_back();
This of course assumes you know the index of your object. This can be known this way
myArray.push_back(object);
object.index = myArray.size()-1
then you removes it with
std::swap(myArray[object.index],myArray.back());
myArray.pop_back();
-
I don't understand. Isn't that just telling the function to iterate through from the beginning to the end and remove all elements with the specified value?
Imagine if you had a list with 1000 elements and you used remove() to remove 10 of them. (This is a pretty realistic example for a game engine.) It would be ridiculously inefficient.
Unfortunately I have no idea how the remove work behind the scene.
-
Yes, I do that all the time. That is the only way to quickly remove an object from a list. For example, in the Entity constructor I do this:
world->entities.push_front(this);
it = world.begin();
And in the destructor I do this:
world.erase(it);
If you use list.remove(this) it has to iterate through the entire list looking for that value, which is very slow. It's amazing how many people don't know this. Look at all these people who think they are experts but don't understand the most basic concepts of data management in C++:
Node need to have iterators dangling around
world->entities.push_front(this); // or world->entities.push_back(this); //... //.. std::remove(world->entities.begin(), world->entities.end(), this);
-
I'm nearly through the lessons. It's actually pretty hard to separate out what the user needs to know and give it to them in a digestable format.
The containers tutorial really makes the problems of C++ iterators glaringly obvious. That's the only way to do fast removal of objects from a list and they are so incredibly error-prone.
Hi there Josh.
First of all the interator sample has an error
std::vector myvector = {"Bob", "Jane", "Fred"}; for (auto it = myvector.begin(); it != myvector.end(); it++) { std::string element = (*it); Print(element); }
should be
std::vector<std::string> myvector = {"Bob", "Jane", "Fred"}; for (auto it = myvector.begin(); it != myvector.end(); it++) { std::string element = (*it); Print(element); }
secondly you can create the vector and iterate in a less mysterious way
if you don't care what myvector actually is.
auto myvector = { "Bob", "Jane", "Fred" }; for each( auto element in myvector ) { Print(element); }
if you do care its
std::vector<std::string> myvector = { "Bob", "Jane", "Fred" }; for each( auto element in myvector ) { Print(element); }
- 1
-
Shame.
From memory you covered most of the topics Josh is after.
Yep. Started with "No knowledge of C++" then covered most things. Classes, Inheritance, Polymorfism, Standard Templates and so on ending up in some Leadwerks scene samples. To bad they are lost and I have no own backup either as I bough a new pc since then and AGAIN!!! was to lazy to make a DVD backup as I had it on YouTube...
-
Hey Roland didn't you do a youtube series on C++ in Leadwerks?
I can't find it. Did you remove it?
Yes I did. But then I switch to a new account, deleted the old one. Of course I forgot to backup them. Yes! Totally idiotic but that's what happened. About 20 videos about C++ lost Sorry about that
- 1
-
-
I keep on getting the error "Asset map value is different" in the Errors tab, although everything seems to work. A bit irritating as that removes focus from the Output tab when running. No errors on the Output tab when loading.
Okay then I though. Lets delete the map and make a new one. Same result and its really not a complicated map. A Terrain and some boxes and spheres.
I have the latest Beta.
Any idea on how to get rid of this annoying thing?
-
Yes this one is really annoying
-
Right down at the right bottom you have 'Who's Online' which is a chat tool
-
Lerp is a linear interpolation. Maybe that would work better?
-
Okidoki... Thanks.
-
Title says it all If answer is YES I'm disappointed as it shouldn't in my humble opinion
-
I've said this before but personally I think Josh should make specific noob friendly engines based off LE's API.
As long as the current "have it all" version is available
- 1
-
Will be there if I manage to figure out what time that is in northern Sweden
-
-
Thanks to Rick that told me how to do
local value = entity.script.param
-
If have an entity in my scene with a script attached that holds some parameter, something like this
Script.param = 10--int
and then in my LUA program at some point picks that entity.
Is is possible to access the script.param then (at this stage I have only the entity)
I made a temporary solution for this that works by using the Get/SetKeyValue like this
Script.param = 10--int function Script:Start() self.entity:SetKeyValue("param", self.param) end
which allows me to get that param event though I only have the entity
local value = entity:GetKeyValue("param")
However this feels a bit odd. Maybe there is some better way ?
Note: In C++ I could do this using my LuaBridge class, but this project is pure LUA
-
Looks really fantastic
-
Nice pics and you also ruined the day for the flatearthers
-
I'm pretty sure this is going to send us back to the pre-Steam days.
Great
-
Solved now.
I created the camera in C++ instead of loading a camera created in the editor and then it works.
auto cam = Camera::Create(); cam->AddPostEffect("Shaders/PostEffects/02_pp_fog_by_klepto.lua"); cam->SetKeyValue("fog_fogrange", "0,20"); cam->SetKeyValue("fog_fogcolor", "0.57,0.53,0.55,1.0"); cam->SetKeyValue("fog_fogangle", "5,21"); cam->SetKeyValue("fog_fogislocal", "0");
- 3
C++ Tutorials
in General Discussion
Posted
Unfortunately I think it's a Microsoft thing, maybe some Linux user can correct me if I'm wrong on that one.