mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
Proofing/review: Remove filler words, adhere to style guide
This commit is contained in:
@@ -41,12 +41,12 @@ Memory model
|
||||
|
||||
PC is a wonderful architecture. Computers often have gigabytes of RAM,
|
||||
terabytes of storage and gigahertz of CPU, and when an application needs
|
||||
more resources the OS will just swap out the inactive ones. Other
|
||||
more resources the OS will swap out the inactive ones. Other
|
||||
architectures (like mobile or consoles) are in general more limited.
|
||||
|
||||
The most common memory model is the heap, where an application will
|
||||
request a region of memory, and the underlying OS will try to fit it
|
||||
somewhere and return it. This often works best and is very flexible,
|
||||
somewhere and return it. This often works best and is flexible,
|
||||
but over time and with abuse, this can lead to segmentation.
|
||||
|
||||
Segmentation slowly creates holes that are too small for most common
|
||||
@@ -59,7 +59,7 @@ However, in many studies and tests, it is shown that given enough
|
||||
memory, if the maximum allocation size is below a given threshold in
|
||||
proportion to the maximum heap size and proportion of memory intended to
|
||||
be unused, segmentation will not be a problem over time as it will
|
||||
remain constant. In other words, just leave 10-20% of your memory free
|
||||
remain constant. In other words, leave 10-20% of your memory free
|
||||
and perform all small allocations and you are fine.
|
||||
|
||||
Godot ensures that all objects that can be allocated dynamically are
|
||||
@@ -103,14 +103,14 @@ which are equivalent to new, delete, new[] and delete[].
|
||||
memnew/memdelete also use a little C++ magic and notify Objects right
|
||||
after they are created, and right before they are deleted.
|
||||
|
||||
For dynamic memory, the DVector<> template is provided. Just use it
|
||||
like:
|
||||
For dynamic memory, the DVector<> template is provided. Use it
|
||||
like this:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
DVector<int>
|
||||
|
||||
DVector is just a standard vector class, it can be accessed using the []
|
||||
DVector is a standard vector class, it can be accessed using the []
|
||||
operator, but that's probably slow for large amount of accesses (as it
|
||||
has to lock internally). A few helpers exist for this:
|
||||
|
||||
@@ -145,7 +145,7 @@ Godot provides also a set of common containers:
|
||||
- Set
|
||||
- Map
|
||||
|
||||
They are very simple and aim to be as minimal as possible, as templates
|
||||
They are simple and aim to be as minimal as possible, as templates
|
||||
in C++ are often inlined and make the binary size much fatter, both in
|
||||
debug symbols and code. List, Set and Map can be iterated using
|
||||
pointers, like this:
|
||||
@@ -189,7 +189,7 @@ StringName
|
||||
|
||||
StringNames are like a String, but they are unique. Creating a
|
||||
StringName from a string results in a unique internal pointer for all
|
||||
equal strings. StringNames are really useful for using strings as
|
||||
equal strings. StringNames are useful for using strings as
|
||||
identifier, as comparing them is basically comparing a pointer.
|
||||
|
||||
Creation of a StringName (especially a new one) is slow, but comparison
|
||||
@@ -204,7 +204,7 @@ Math types
|
||||
----------
|
||||
|
||||
There are several linear math types available in the core/math
|
||||
directory, they are basically just that.
|
||||
directory.
|
||||
|
||||
References:
|
||||
~~~~~~~~~~~
|
||||
|
||||
@@ -202,7 +202,7 @@ SDK library
|
||||
|
||||
So, finally it's time to add the SDK library. The library can come in
|
||||
two flavors, a JAR file or an Android project for ant. JAR is the
|
||||
easiest to integrate, just put it in the module directory and add it:
|
||||
easiest to integrate, put it in the module directory and add it:
|
||||
|
||||
.. code:: python
|
||||
|
||||
@@ -263,7 +263,7 @@ This will cause your module to be included, the .jar will be copied to
|
||||
the java folder, the .java will be copied to the sources folder, etc.
|
||||
Each time you modify the .java, scons must be called.
|
||||
|
||||
Afterwards, just continue the steps for compiling android :ref:`doc_compiling_for_android`.
|
||||
Afterwards, continue the steps for compiling android :ref:`doc_compiling_for_android`.
|
||||
|
||||
Using the module
|
||||
~~~~~~~~~~~~~~~~
|
||||
@@ -285,7 +285,7 @@ More than one singleton module can be enabled by separating with commas:
|
||||
|
||||
modules="org/godotengine/godot/MySingleton,corg/godotengine/godot/MyOtherSingleton"
|
||||
|
||||
Then just request the singleton Java object from Globals like this:
|
||||
Then request the singleton Java object from Globals like this:
|
||||
|
||||
::
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ this module:
|
||||
# SCsub
|
||||
Import('env')
|
||||
|
||||
env.add_source_files(env.modules_sources,"*.cpp") # just add all cpp files to the build
|
||||
env.add_source_files(env.modules_sources,"*.cpp") # Add all cpp files to the build
|
||||
|
||||
With multiple sources, you can also add each file individually to a Python
|
||||
string list:
|
||||
@@ -227,8 +227,7 @@ your module will be included.
|
||||
Using the module
|
||||
----------------
|
||||
|
||||
Using your newly created module is very easy, from any script you can
|
||||
now do:
|
||||
You can now use your newly created moedule from any script:
|
||||
|
||||
::
|
||||
|
||||
@@ -406,15 +405,14 @@ one of the ``ClassName.xml`` files and recompile the engine from now on.
|
||||
Summing up
|
||||
----------
|
||||
|
||||
As you see, it's really easy to develop Godot in C++. Just write your
|
||||
stuff normally and remember to:
|
||||
Remember to:
|
||||
|
||||
- use ``GDCLASS`` macro for inheritance, so Godot can wrap it
|
||||
- use ``_bind_methods`` to bind your functions to scripting, and to
|
||||
allow them to work as callbacks for signals.
|
||||
|
||||
But this is not all, depending what you do, you will be greeted with
|
||||
some surprises.
|
||||
some (hopefully positive) surprises.
|
||||
|
||||
- If you inherit from :ref:`class_Node` (or any derived node type, such as
|
||||
Sprite), your new class will appear in the editor, in the inheritance
|
||||
|
||||
@@ -204,7 +204,7 @@ example:
|
||||
|
||||
If cast fails, NULL is returned. This system uses RTTI, but it also
|
||||
works fine (although a bit slower) when RTTI is disabled. This is useful
|
||||
on platforms where a very small binary size is ideal, such as HTML5 or
|
||||
on platforms where a small binary size is ideal, such as HTML5 or
|
||||
consoles (with low memory footprint).
|
||||
|
||||
Signals
|
||||
|
||||
Reference in New Issue
Block a user