-
Hi, I was writing my custom renderer and noticed this subtle difference-- If I initialize my I wonder what are the differences between these two initialization methods, and which one is the standard way to go. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @Ginko2501 The default constructor will just allocate the memory, but will not initialize it. As a general rule of thumb, I use |
Beta Was this translation helpful? Give feedback.
Hi @Ginko2501
The default constructor will just allocate the memory, but will not initialize it.
For
initialize_sh_frame()
to work, both thesi.sh_frame.n
anddp_du
fields needs to be initialized. This is why it would crash if you only initialize the former.As a general rule of thumb, I use
dr.zeros
everytime I allocate a new variable. If you take a look at some of the source code (Python or C++) you'll see that this is quite common.