Rtti for game development tips (1)

Source: Internet
Author: User

First of all, I want to explain the meaning of the title. How do I feel like defining a language? I need a protocol .....

The title is defined as follows: Game Development tip + content + (the number of total Tips)

The extension is as follows: content (1, 2, 3 .....)

Poor Newbie. Every word of the great God may be hidden, but the novice cannot understand it immediately (if you understand it immediately, it is estimated that it will become the same level as the great God ). Start text.

Great gods said that a good game engine should provide a good rtti. Of course, the game engine can be implemented by itself. The game engine can also not implement its own rtti. In this case, developers need to write their own rtti.

Why?

Why not use the rtti provided by C ++? No matter which type of conversion is provided by C ++, it is especially resource-consuming.

Think of the GetType () Field written by the predecessors in the current project (). Based on this type, you can determine which subclass is in. At that time, I was not quite clear. I thought this was not an extra move? One dynamic_cast can solve the problem, but it still has to be difficult to assign values to the type.

At this point, I understand this method, but it is a little late. Why is it late .... This... Don't talk about it anymore ....

I searched for my post on the Internet to implement the rtti function. The post also says:

"The runtime dynamic type check (rtti, run time type indentifiation) is a language mechanism provided in C ++. It is mainly used to determine the specific type of A polymorphism object.
Why not use the rtti function provided by C ++ 
However, rtti directly provided in C ++ has some disadvantages. First, it provides the function to obtain the class name (name function in typeinfo). This function is not actually required by rtti. In many cases, we don't need to get the class name, but just want to judge the specific type of an object. In addition, the name obtained by typeinfo is not necessarily portable, and the type names obtained by different compilers are not necessarily the same.
Secondly, in most cases, if rtti is enabled, all polymorphism classes in the program will add the rtti information overhead, however, we often only need to select some of the classes with the rtti function.
In general, the rtti provided by C ++ is not controllable because it is related to the compiler. Therefore, we need to implement an rtti by ourselves. "

I can't quite understand what the above text says. Remember a tip.

Original article link: http://m.blog.csdn.net/blog/s_51563946/4465502

In order to prevent bloggers from processing the blog, the blog had to re-post it: http://www.cnblogs.com/slysky/p/3904227.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.