Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, NeoDumont), 761 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: [???] View-Frustum [Re: maslone1] #379234
07/30/11 19:27
07/30/11 19:27
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
The reason why it looks like you could cram larger values into the variable is dead simple and lies in the roots of C. C is statically typed meaning that all type information is only available at compile time so the compiler can pick the right commands to work with the data. At runtime the type data isn't needed and the code just runs the same commands no matter what you give it as input.

Consider this function:
Code:
void foo(int bar)
{
   printf("Hey, the passed parameter is a int and it is: %i", bar);
}



Now we call the function, lets say like this: foo(23);
You can imagine what it prints, right?

Now consider this here:
Code:
STRING *baz = "HAHA, suck that";
...
foo((int)baz);



The compiler won't complain because you explicitly told it that you know that an int is expected, you gave no int but everything is perfectly right (there are various legit reasons to allow this). Anyway, it won't magically print your string but interpret the pointer to the string you passed it as an int resulting in the printf printing the address of that pointer...


So, back to what you did: You changed that data type to int, now the compiler sees that there is an int expected where previously you had a var. To get this clear, this doesn't change the struct at all as the engine is already compiled to expect var! The header is just their so the compiler knows what you mean with eg. camera->clip_factor, so that it knows at which memory address it can get the data. If you change it, you alter the commands your program runs, not the one the already compiled engine runs.
So now that you changed this to an int, the compiler will do implicit typecasting. So if you pass a var or a size_t whereas the data type is an int, it will typecast it for you (this works only in some cases where the signdes doesn't change and the data types have the same size). Anyway, you will now see an int and you can print an int, but the engine still uses var so it interprets the value other than you do.

Hope this clarifies the whole issue so far.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: [???] View-Frustum [Re: WretchedSid] #379235
07/30/11 19:36
07/30/11 19:36
Joined: Jul 2007
Posts: 424
EUROPE
maslone1 Offline OP
Senior Member
maslone1  Offline OP
Senior Member

Joined: Jul 2007
Posts: 424
EUROPE
Perfect explain!
Thank you!

But it is still interesting for me to be able to use a value of ca. -2'097'000 to +2'097'000 in tne camera.clip_far (var unchanged).

I hope you have time to explain this too for me
(i like your explains, very clear, just direct facts, easy to understand)


Last edited by maslone1; 07/30/11 19:37.

A8c, Blender, FlStudio, Unity3d
Re: [???] View-Frustum [Re: maslone1] #379237
07/30/11 20:05
07/30/11 20:05
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Originally Posted By: maslone1

(i like your explains, very clear, just direct facts, easy to understand)

Thanks laugh

The problem is, you can't change the var type. Its has a fixed size (4 bytes) and thus is limited by them. As you can't change the data type, you can't fix it this way but what you could do is to scale everything down. Your models, your levels, everything, by the factor that you need to get the results you want with the range of a var.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: [???] View-Frustum [Re: WretchedSid] #379241
07/30/11 20:40
07/30/11 20:40
Joined: Jul 2007
Posts: 424
EUROPE
maslone1 Offline OP
Senior Member
maslone1  Offline OP
Senior Member

Joined: Jul 2007
Posts: 424
EUROPE
Thanks again.

So back to the basics. I've already startet to create a conzept to handle the big objects. Sadly,.... now i have to write it smirk wink


So thanx again JustSid

CU
Marcel


A8c, Blender, FlStudio, Unity3d
Page 2 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1