« first day (2997 days earlier)      last day (2021 days later) » 

1:28 AM
I could use some help. How do I save variables to a binary or text file and read it again in Unity with C#? Everywhere I look recommends to save by serializing or JSON for human-reading for human view, but I am not concerned with that. C seemed to allowed it pretty easily to save in binary, but, to me, 100 lines of code seems silly to save in JSON for sake of readability
 
what kind of variables do you have?
is it in a class?
 
It is just a few integers (and no they are not in a class, I hardly even know what those are)
 
if you want to write individual primitives, you can use BinaryReader/BinaryWriter
 
Not in the docs. What is it exactly?
 
the issue is that if your format never changes, you can just write some values. but for example, if you ever want to add a header to your file or re-order some fields, then everything breaks, which is why people recommend serialization
oh ,these aren't Unity, these are .NET classes
 
1:43 AM
OH. Crap. I am thinking of just sticking with PlayerPrefs....
All what Google has offered is alot of complex, secure, and human-readable formats, none in which concerns me with my little pet project.
 
I imagine Unity probably has an odd set of APIs because its API needs to work on phones and web and consoles where you might not have the same kind of files as on PC
 
Of course it does.... What is a "Class" in C#?
 
a class is like a class in C++
it's like a struct in C, roughly
 
Or more of "Why does Unity even add the scripting documentations on complex stuff? They don't explain it at all"
 
in C#, and languages like it (i.e. Java), all functions live in a class
 
1:51 AM
Ok. A structure...
 
so in C, where you had global functions printf and fprintf to write to the console and to a file respectively, in C# you have things like System.Console and System.IO.StreamWriter which are structures
 
Ok... is it like C where you define a location and the variable and it writes to the location?
 
hmm, there's several ways to do this. maybe I'll show you the "dumbest" way since it might be the easiest to understand
 
Please
 
StreamReader and StreamWriter kind of just write a line of text to a file
You can ask StreamReader to read a line of text, and you can then call int.Parse() to turn that string into an int
for example, int.Parse("345") == 345
 
2:13 AM
Wait, how could I parse any string number into an usable integer?
Nvm. I think I almost got it
It is telling me "Input String was not in the correct format"
I got it!
 
yeah if the ReadLine returned something like an empty string, or "x" then it will not work
 
I gotta go to bed. Thanks for the help. Might come back for more help on this within the next few days. Bye
 
later
 
 
14 hours later…
user92578
4:17 PM
Is there a common pattern for dispatching work to a specific thread, in this case the main thread?
 
user92578
Currently if my content loader is asked to load something on another thread, and it can't (like it needs to access the GPU or something), it does everything it can and pushes a temporary data object into a vector
 
user92578
Then once a frame, the main thread calls a method of the content loader that processes that vector and performs whatever it is that needs to be done on the main thread
 
user92578
The solution works just fine but doesn't seem very clean to me, and I'm starting to have quite a few vectors for different types of data that need to be processed on the main thread
 
user4704
4:56 PM
@Tyyppi_77 Yeah, but generally you don't want to dispatch "work" to a specific thread.
 
user4704
Although in this case it does seem appropriate.
 
user4704
Or at least, to dispatch to a specific thread (not neccessarily the main one)
 
user4704
But generally I'd think the solution here is to either avoid the "content loader" needing to create GPU resources (which means the loading thread is there to basically avoid disk IO stalling the main thread)
 
user4704
or to do what you're doing; build as much of the GPU resource as you can on the loader thread and then do it all on the GPU's thread when you get the chance
 
user4704
If the objection you're having is that you have a bunch of different kinds of vectors to hold pending-GPU-resource data, you can build a sort of command-buffer-like abstraction where you just have a bunch of opaque commands in a single buffer, switch on the first few bytes of the command (which represen the type) and create the resources that way
 
user92578
5:02 PM
So due to the way SDL internals work, I currently have four different cases that I need to handle: sound, music, textures from disk and render targets
 
user4704
Oh, not all diffent kinds of GPU resources, I see.
 
user4704
I'd probably keep those in different queues myself, but I suppose you still could do the unified-command-buffer approach
 
user92578
I guess what really annoys me, but might actually be a whole different issue from what I described, is the deletion of said resources.
 
user4704
You could at least get it down to two (audio/graphics)
 
user92578
Before I can safely destroy something, I need to first check if it's actually yet to be loaded, and clear the item from the queue and so on
 
user4704
5:05 PM
Do you ever really run into scenarios where you end up requesting the deletion of a resource before it's loaded?
 
user92578
Apparently I do since that code was not initially there, added only after like a weekend of debugging of weird crashes at startup
 
user4704
Most of the time, I've just seen engines handle this through the natural queue order: the load request will go in, logic will eventually cause a delete, and then the delete request will go in after the load
 
user4704
And it will just load the thing, create all the stuff... and then delete it
 
user4704
Hm, interesting.
 
user92578
This is actually only the case with render targets I believe, since the content loader owns everything else
 
user4704
5:07 PM
I mean, I guess you'd just traverse (or look up) into the load queue to find outstanding requests and delete them, but you might have to put concurrency guards around the case where the thing is actively being loaded, and not just in the queue?
 
user92578
All right so I guess it kinda sounds like my system is relatively fine then. I gotta go, thanks for the code design rubber ducking or whatever this ended up being :)
 
user4704
np
 
6:10 PM
I'm idly considering making a flight simulation video game.
 
user4704
I always liked those when I was a kid.
 
Like Kerbal Space Program, but all about atmospheric flight, no spaceflight.
("Kerbal Air Program"?)
So, designing planes (and other aircraft, like gliders and helicopters) and then flying them.
The "tricky bit" is the flight model.
If I were to do this, I'd like to not half-ass the flight model; I'd like to get something reasonably realistic. Where, if you build a replica of a Cessna 172, it'll at least kind of fly like a Cessna 172.
Now... I'm guessing I can't just grab an aerodynamics simulation package from GitHub and use that. :D
 
user4704
i dunno, i'd guess no but I've never looked
 
I think they say that X-Plane is the most realistic flight simulator. So ideally I'd use the X-Plane aerodynamics model... but even if that were technically feasible, it would probably be prohibitively expensive to license it.
 
6:35 PM
I've got a reasonable idea for how to "fake it". Just simulate the aerodynamics for each individual part and add all that together. I can use raycasting to make a not-completely-awful simulation of blanketing.
Now all I gotta do is... win the lottery and then quit my job so I have the resources to actually do this.
 
7:23 PM
github.com/gabrielevierti/OMGE/blob/master/Engine/… it's working now, i also wanted to use find_library(), but the cmake specification does not provide any example of its usage..
find_library (<VAR> name1 [path1 path2 ...])
 
user4704
7:40 PM
It's just find_library(GLFWLibrary NAMES glfw3.lib PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib)
 
user4704
for example
 
user4704
Then you use "GLFWLibrary" or whatever when you need ot refer to it
 
user4704
I guess you'd probably want NO_DEFAULT_PATH on the end
 
user4704
but yeah. It's in the docs there. What you pasted is basically the example
 
8:21 PM
@Josh I remember trying that, but it didn't work..
 
user4704
That's what debugging is for. You can use message() to dump values during the configuration phase and see what you are doing wrong.
 
oh, okay then. thanks
oh yeah i remember using find library, i just didn't put the .lib extension after the name
find_library (glfw_lib NAMES glfw3.lib PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib)
find_library (irrklang_lib NAMES irrKlang.lib PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib)
find_library (vulkan_lib NAMES vulkan-1.lib PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib)

target_link_libraries (Omge glfw_lib irrKlang_lib vulkan_lib)
target_link_libraries does not seem to treat the variables like libraries..
 
user4704
8:39 PM
Make sure they actually got found; examine what's in glfw_lib
 
user4704
If it contains "-NOTFOUND" then it wasn't found
 
8:50 PM
they are all found
they all point to the correct folder and correct lib file
 

« first day (2997 days earlier)      last day (2021 days later) »