[QUOTE=LoneWolf;8602]Also implemented Multithreaded loading through the Thread class. Loading every model and texture in a separate thread. Will extend it later so it will automatically allocate x number of threads where x is not greater than CPU cores.[/QUOTE]
I’d suggest 1) Not dealing with the Thread class directly. 2) Look at the TaskParallelLibrary, which is included in 4.0 and as part of ReactiveExtensions in 3.5. 3) If you can’t do that, use the ThreadPool class.
You don’t want to limit your threads to be equal to the CPU cores- that buys you nothing. What you can do is try to bind a thread to a certain hardware core, but that’s a complex concept.
My point is, work with the higher-level thread management systems already available, and then once you fully understand them, make your own thread management decisions/system if necessary.
Threading is an extremely complex concept that can easily bite you in the ass if you don’t fully understand how you’re using it.
Yeah I know about the awesome stuff in 4.0 but I’m not ready to switch yet because of time constraints. While I switch I also want to switch XNA 3.1 to 4.0 which will require some modifying here and there because of API changes.
Hmm though I don’t get why I wouldn’t want to limit the threads to the CPU core amount. I thought the distribution to the cores was handled by the OS, unless I’m mistaken. I know I can set the affinity to a certain core manually if that’s what you mean (which is required on the Xbox 360 since some cores are reserved for XNA).
What I had in mind though was something like the system Dice uses in their Frostbite Engine where I have Tasks and then I queue up them in a TaskManager. The TaskManager then looks for idle Threads and then queues them up and then starts it after all the tasks are queued. Then if a certain task is finished too early it steals the tasks of the other threads through Task stealing. But that again is implemented in 4.0 which I will have when I switch over to it, so I see no need to do this myself for now ateast
So I believe I will not touch any threading for now other than what I have for loading the content
Once I switch over when I have time, I’ll start using the new features with task stealing and such that comes with 4.0 =}
Though still can’t decide if I’m gonna have an asynchronous game loop where everything run in a separate thread and if something isn’t done the renderer uses the old values through double buffering (more memory but yeah, still fun to actually make something like this =} )
Other than that programmers at my work are explaining things quite good so I’ve been learning too much lately by just social engineering xD So many terms like Critical Sections, Mutex, Moniter, Walls you name it. But yeah
I’m still working towards collision systems and maybe even self collision We’ll see!
Quick overview: it is vertices with springs. A spring is basically a class with index to VertexA, VertexB and OriginalLength between the vertices. Whenever vertices are too far away from the original length the spring drag them together, when they are too close it pushes them away. Then you have the regular velocity and stuff such as particles has. But we dont store the velocity explicitely. Instead we calculate it by old pos and new pos before updating.
Generating the vertices is dual for loops for positioning. Then generating the constraints is basic algebra inside a forloop to get the correct verticex indices and assign them to VertexA and VertexB. Later these Indices are used to look inside an array that holds all the vertices while looping over all the constraints.
The algorithms provides on that article is very nice and very fast, perfect for interactivity, and they are very simple to understand! Been used on the game Hitman I believe, as they state!
Took me about 2 hours to implement this after reading that article, where I spent about 20 minutes maybe graphing and testing, drawing etc defo worth reading!
EDIT: Zomg!! It just hit in my head how I can make tearable cloth Last in my prio list but I will defo implement it! When springs can’t get the desired length in x amount of time, tearing will happen if and only if the length is more than tearing length and it keeps getting longer during the relaxation step ^^ Scenarios that can cause that is too much instant force with pinned vertices, maybe a sword swing or something etc ^^
Things are going quite slow atm but I’m still progressing. Didn’t have much time lately been busy with other stuff. The current status for this right is the property grid, i’m making it easier to work with by adding support for tabbing in and out of stuff, also making it visually easier to work with and even buttons to take you directly to the documentation for each property such as Transform, Renderer etc. Though no documentation has been done for now.
I’ll try to squeeze in an update or two this weekend. Will probably work on the script system. It’s almost done but not working as intended When I assign C# scripts (class that derives ScriptBehaviour and overrides Update and a few more events if wanted) through drag/dropping; it runs inside the editor, which it obviously shouldn’t. A constant move script makes my objects move haha. The property grid automatically sees that a script has been assigned and it lists all its public properties in the propertygrid, allowing me to edit and save down the values per level =}
I also have plans on making prefabs, gosh more XML love XNA intermediate serializer because of cross referencing is so easy to handle (GameObject 0 and 1 pointing to same material for example) and I can compile them to binary later which is needed for Xbox to be loadable =}
Compilation is already done through the Build and Project classes as I posted some time ago, so I’m not actually far away from making this editor workable =}
I’ve been spawning some ideas with some RL friends on making a small game or so, but we are quite busy all of us right now so it’s at its earliest stages where we just spawn stupid ideas
The video I’ve posted shows that you write a class inheriting ScriptBehaviour, then you overload the Update method so the engine can run it.
Once done you can expose variables to the editor with the attribute called [Browsable(true)] which you’ll see me doing in the video.
Then you can start drag dropping the scripts in the editor to objects in the scene and they’ll start running it if enabled is true iin the propertygrid.
I’m showing 3 scripts in the movie, those are Spin, MoveForward and SineScale, and that they indeed get listed in the PropertyGrid of the editor after drag drop assignment.
For some reason camstudio didn’t render my Drag and Drop operation mouse cursor while assigning scripts so it still shows the regular mouse cursor, so it might be hard to see when I’m doing the drag and drop operation unless you follow my mouse