Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
0 registered members (), 631 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 3 1 2 3
Re: How can i make a copy of a MATERIAL? [Re: Aku_Aku] #400915
05/09/12 16:51
05/09/12 16:51
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Could you in turn explain why you're so keen on blindly copying memory around and messing with internals of the engine when there is a clean and easy way to achieve what you originally wanted?


Always learn from history, to be sure you make the same mistakes again...
Re: How can i make a copy of a MATERIAL? [Re: Uhrwerk] #400916
05/09/12 16:59
05/09/12 16:59
Joined: Sep 2009
Posts: 987
Budapest
Aku_Aku Offline OP
User
Aku_Aku  Offline OP
User

Joined: Sep 2009
Posts: 987
Budapest
Truly... No. Just, laziness. Or, endeavour to simplicity.

Re: How can i make a copy of a MATERIAL? [Re: Aku_Aku] #400922
05/09/12 20:03
05/09/12 20:03
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Originally Posted By: Aku_Aku
I can't see what problem should be when PARENT material gets destroyed.
I have a solid copy of that. IMHO the new one isn't child, just another another, independent material.
And how could be memory leak happen?

To answer both questions at once: You are doing a shallow copy, so you just copy the values of pointers instead of doing a deep copy with everything. If the parent material gets removed, your copy material suddenly has lots of dangling pointers...
Oh and you leak the memory that was allocated for your material, but you threw away while doing the copy.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: How can i make a copy of a MATERIAL? [Re: WretchedSid] #400930
05/09/12 21:43
05/09/12 21:43
Joined: Sep 2009
Posts: 987
Budapest
Aku_Aku Offline OP
User
Aku_Aku  Offline OP
User

Joined: Sep 2009
Posts: 987
Budapest
I don't understand why do you write PARENT? IMHO my new material isn't CHILD just another FELLOW.
So, please explain this parent thing.....

Another thing, might not destroy the original one.
Because that is mat_model. Who would be so brave to destroy that?

Re: How can i make a copy of a MATERIAL? [Re: Aku_Aku] #400933
05/09/12 23:06
05/09/12 23:06
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Its a parent because the copy inherits everything from it. But even if it was just a fellow, the problem still persists.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: How can i make a copy of a MATERIAL? [Re: WretchedSid] #401079
05/13/12 09:01
05/13/12 09:01
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
Could someone explain to me why this would not work as i don't
understand why go the complicated route . Material* one=two


Compulsive compiler
Re: How can i make a copy of a MATERIAL? [Re: Wjbender] #401080
05/13/12 09:23
05/13/12 09:23
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Because that is not a deep copy. Material* one = two, here you set the value of your pointer 'one' so that it points to the same material data as 'two'.

Code:
Material* one;
Material* two = mtl_create(...);
one = two;

gives you:

one ------->| material |
two ------->| data     |

Thus deleting or modifying the actual material data affects both one and two!
whereas

Material* one;
Material* two = mtl_create(...);
material_cpy( one, two );

gives you

one ------> [ Material data ]

two ------> [ Material data ]

and any change in material data one does not affect the material data of two.




Click and join the 3dgs irc community!
Room: #3dgs
Re: How can i make a copy of a MATERIAL? [Re: Joozey] #401082
05/13/12 10:04
05/13/12 10:04
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
Okay i guess what confused me was "make a copy"


Compulsive compiler
Page 3 of 3 1 2 3

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