C4D Programming

Developing plugins and scripts for CINEMA 4D

Tag: Optimization

Vectors: GetLength() vs. GetLengthSquared()

by .

There are a lot of situations where you need to get the length of a vector. For example, if you want to measure the distance between two objects. But there are also a lot of situations where you don’t need the actual length of the vector, because maybe you just want to find out which vector is the shortest. For example, if you want to determine which object – out of a group of objects – is closes to a given position; a common task if you deal with particle systems where particles have to interact with their closest neighbors.
Read the rest of this entry »

Initializing member variables in the constructor

by .

As you might know, it is good practice to leave no variables uninitialized. If you wrote a struct or class, all its members should have a defined initial state, which is usually set in the struct’s or class’s constructor.
Read the rest of this entry »

Function parameters as references

by .

Performance can be increased by using references instead of copying values as function arguments.
Read the rest of this entry »