Conventions

Urho3D uses the following conventions and principles:

  • Left-handed coordinates. Positive X, Y & Z axes point to the right, up, and forward, and positive rotation is clockwise.
  • Degrees are used for angles.
  • Clockwise vertices define a front face.
  • Audio volume is specified from 0.0 (silence) to 1.0 (full volume)
  • Path names use slash instead of backslash. Paths will be converted internally into the necessary format when calling into the operating system.
  • In the script API, properties are used whenever appropriate instead of Set...() and Get...() functions. If the setter and getter require index parameters, the property will use array-style indexing, and its name will be in plural. For example model->SetMaterial(0, myMaterial) in C++ would become model.materials[0] = myMaterial in script.
  • Raw pointers are used whenever possible in the classes' public API. This simplifies exposing functions & classes to script, and is relatively safe, because SharedPtr & WeakPtr use intrusive reference counting.
  • When an object's public API allows assigning a reference counted object to it through a Set...() function, this implies ownership through a SharedPtr. For example assigning a Material to a StaticModel, or a Viewport to Renderer. To end the assignment and free the reference counted object, call the Set...() function again with a null argument.
  • No C++ exceptions. Error return values (false / null pointer / dummy reference) are used instead. Script exceptions are used when there is no other sensible way, such as with out of bounds array access.
  • Feeding illegal data to public API functions, such as out of bounds indices or null pointers, should not cause crashes or corruption. Instead errors are logged as appropriate.
  • Third party libraries are included as source code for the build process. They are however hidden from the public API as completely as possible.

For more details related to the C++ coding style, see also Coding conventions.