diff --git a/cocos/core/utils/decode-uuid.ts b/cocos/core/utils/decode-uuid.ts
index 955c9c8d1c..0b270679e6 100644
--- a/cocos/core/utils/decode-uuid.ts
+++ b/cocos/core/utils/decode-uuid.ts
@@ -27,23 +27,23 @@ import { TEST } from 'internal:constants';
import { BASE64_VALUES } from './misc';
import { legacyCC } from '../global-exports';
-const seperator = '@';
+const separator = '@';
const HexChars = '0123456789abcdef'.split('');
const _t = ['', '', '', ''];
const UuidTemplate = _t.concat(_t, '-', _t, '-', _t, '-', _t, '-', _t, _t, _t);
-const Indices = UuidTemplate.map((x, i) => (x === '-' ? NaN : i)).filter(isFinite);
+const Indices = UuidTemplate.map((x, i) => (x === '-' ? NaN : i)).filter(Number.isFinite);
/**
* @en
- * Decode uuid, returns the original uuid
+ * Decode base64-compressed uuid.
*
* @zh
- * 解码 uuid,返回原始 uuid
+ * 解码用 base64 压缩过的 uuid。
*
- * @param base64 - the encoded uuid
- * @returns the original uuid
+ * @param base64 @en Base-64 compressed uuid. @zh 用 base-64 压缩过的 uuid。
+ * @returns @en Original uuid. @zh 未压缩过的 uuid。
*
* @example
* ```ts
@@ -52,7 +52,7 @@ const Indices = UuidTemplate.map((x, i) => (x === '-' ? NaN : i)).filter(isFinit
* ```
*/
export default function decodeUuid (base64: string) {
- const strs = base64.split(seperator);
+ const strs = base64.split(separator);
const uuid = strs[0];
if (uuid.length !== 22) {
return base64;
diff --git a/cocos/core/utils/id-generator.ts b/cocos/core/utils/id-generator.ts
index b915ca9a82..07761d7e6a 100644
--- a/cocos/core/utils/id-generator.ts
+++ b/cocos/core/utils/id-generator.ts
@@ -31,7 +31,7 @@ const NonUuidMark = '.';
* ID generator for runtime.
*
* @zh
- * 运行时 ID 生成器
+ * 运行时 ID 生成器。
*/
export class IDGenerator {
/**
@@ -44,26 +44,42 @@ export class IDGenerator {
*/
public static global = new IDGenerator('global');
+ /**
+ * @en A number to record current id. It may increase when invoke `getNewId()`. Should use
+ * `getNewId()` to get a unique id.
+ * @zh 记录当前 id 值。调用 `getNewId()` 时,它可能被加1。应该使用 `getNewId()` 获取唯一的 id。
+ */
public id: number;
+ /**
+ * @en A string value indicates the category this IDGenerator belongs to. It will be an empty
+ * string if not be assigned by passed parameter in constructor.
+ * @zh 用于标识该 IDGenerator 所属的类别。如果构造函数没有传参数对它赋值的话,它将是一个空字符串。
+ */
public prefix: string;
/**
- * @en Construct a new id generator
- * @zh 构造一个新的 id 生成器
+ * @en Construct a new id generator.
+ * @zh 构造一个新的 id 生成器。
*
- * @param [category] @en You can specify a unique category to avoid id collision with other instance of IdGenerator. @zh 你能指定一个唯一的标识用于避免与其他 id 生成器冲突
+ * @param category @en You can specify a unique category to avoid id collision with other instance of IdGenerator.
+ * @zh 你能指定一个唯一的标识用于避免与其他 id 生成器冲突。
*/
constructor (category?: string) {
- // Tnit with a random id to emphasize that the returns id should not be stored in persistence data.
+ // Initialize with a random id to emphasize that the returns id should not be stored in persistence data.
this.id = 0 | (Math.random() * 998);
this.prefix = category ? (category + NonUuidMark) : '';
}
+ /**
+ * @en Gets a unique id. @zh 获取唯一的 id。
+ * @returns @en The unique id. It has the form `prefix+id`, for example `scene55`, `scene` is `prefix`, `55` is `id`.
+ * @zh 唯一的 id。它的形式是 `prefix+id`,比如 `scene55`,`scene` 是 prefix,`55` 是 `id`。
+ */
public getNewId () {
if (EDITOR && (this.prefix === 'Node.' || this.prefix === 'Comp.')) {
return EditorExtends.UuidUtils.uuid();
}
- return this.prefix + (++this.id);
+ return this.prefix + (++this.id).toString();
}
}
diff --git a/cocos/core/utils/js-typed.ts b/cocos/core/utils/js-typed.ts
index ccc295e667..0cb880e42c 100644
--- a/cocos/core/utils/js-typed.ts
+++ b/cocos/core/utils/js-typed.ts
@@ -34,13 +34,20 @@ const classIdTag = '__cid__';
/**
* @en
- * Check the object whether is number or not
- * If a number is created by using 'new Number(10086)', the typeof it will be "object"...
- * Then you can use this function if you care about this case.
+ * Checks if an object is `number`.
* @zh
- * 检查对象是否是 number 类型,如果通过 'new Number(10086)' 创建了一个数字,则使用 typeof 判断此数字时,将返回 'object' 类型,此时你可以通过此方法来进行判断
- * @param object object to be checked
- * @return whether this object is number or not
+ * 检查对象是否是 number 类型。
+ * @param object @en The object to check. @zh 要检查的对象。
+ * @returns @en True if it is a number primitive or a `Number` instance, false else.
+ * @zh 如果该对象是基础数字类型或者是 `Number` 实例,返回 `true`;否则返回 `false`。
+ * @example
+ * ```ts
+ * var obj = 10;
+ * isNumber(obj); // returns true
+ *
+ * obj = new Number(10);
+ * isNumber(obj); // returns true
+ * ```
*/
export function isNumber (object: any) {
return typeof object === 'number' || object instanceof Number;
@@ -48,13 +55,20 @@ export function isNumber (object: any) {
/**
* @en
- * Check the object whether is string or not.
- * If a string is created by using 'new String("blabla")', the typeof it will be "object"...
- * Then you can use this function if you care about this case.
+ * Checks if an object is `string`.
* @zh
- * 检查对象是否是 string 类型,如果通过 'new String("blabla")' 创建了一个字符串,则使用 typeof 判断此字符串时,将返回 'object' 类型,此时你可以通过此方法来进行判断
- * @param object object to be checked
- * @return whether this object is string or not
+ * 检查对象是否是 string 类型。
+ * @param object @en The object to check. @zh 要检查的对象。
+ * @returns @en True if it is a string primitive or a `String` instance, false else.
+ * @zh 如果该对象是基础字符串类型或者是 `String` 实例,返回 `true`;否则返回 `false`。
+ * @example
+ * ```ts
+ * var obj = "it is a string";
+ * isString(obj); // returns true
+ *
+ * obj = new String("it is a string");
+ * isString(obj); // returns true
+ * ```
*/
export function isString (object: any) {
return typeof object === 'string' || object instanceof String;
@@ -62,11 +76,13 @@ export function isString (object: any) {
/**
* @en
- * Checks if the object `obj` does not have one or more enumerable properties (including properties from proto chain).
+ * Checks if an object is empty object. If an object does not have any enumerable property
+ * (including properties inherits from prototype chains), then it is an empty object.
* @zh
- * 检查此对象是否为空对象
- * @param obj The object.
- * @returns The result. Note that if the `obj` is not of type `'object'`, `true` is returned.
+ * 检查对象是否为空对象。空对象的定义是:没有任何可被枚举的属性(包括从原型链继承的属性)的对象。
+ * @param obj @en The object to check. @zh 要检查的对象。
+ * @returns @en True if it is not an empty object or not an object, false else.
+ * @zh 如果不是空对象或者不是一个对象,返回 `true`;否则返回 `false`。
*/
export function isEmptyObject (obj: any) {
for (const key in obj) {
@@ -76,14 +92,15 @@ export function isEmptyObject (obj: any) {
}
/**
- * @en
- * Define value, just help to call Object.defineProperty.
- * The configurable will be true.
- * @zh
- * 定义值,帮助调用 Object.defineProperty.
- * 该属性默认可读写
- * @param [writable=false]
- * @param [enumerable=false]
+ * @en A helper function to add a property to an object, or modifies attributes
+ * of an existing property. The property is configurable.
+ * @zh 为对象添加属性或者修改已有属性的辅助函数。该属性是可配置的。
+ * @param object @en The object to add or modify attributes. @zh 要添加或者修改属性的对象。
+ * @param propertyName @en The property name to add or modify. @zh 要添加或修改的属性名。
+ * @param value_ @en The property value to add or new value to replace a existing attribute.
+ * @zh 要添加的属性值,或者取代现有属性的新值。
+ * @param writable @en If the property is writable. @zh 属性是否可写。
+ * @param enumerable @en If the property is enumerable. @zh 属性是否可枚举。
*/
export const value = (() => {
const descriptor: PropertyDescriptor = {
@@ -102,13 +119,14 @@ export const value = (() => {
})();
/**
- * @en
- * Define get set accessor, just help to call Object.defineProperty(...).
- * @zh
- * 定义 get set 访问器,帮助调用 Object.defineProperty()
- * @param [setter=null]
- * @param [enumerable=false]
- * @param [configurable=false]
+ * @en A helper function to add or modify `get`, `set`, `enumerable` or `configurable` of a property.
+ * @zh 添加或修改属性的 `get`, `set`, `enumerable` 或者 `configurable`。
+ * @param object @en The object to add or modify attributes. @zh 要添加或者修改属性的对象。
+ * @param propertyName @en The property name to add or modify. @zh 要添加或修改的属性名。
+ * @param getter @en The getter of a property. @zh 属性的获取函数。
+ * @param setter @en The setter of a property. @zh 属性的设置函数。
+ * @param enumerable @en If the property is enumerable. @zh 属性是否可列举。
+ * @param configurable @en If the property is configurable. @zh 属性是否可配置。
*/
export const getset = (() => {
const descriptor: PropertyDescriptor = {
@@ -118,6 +136,7 @@ export const getset = (() => {
};
return (object: Record, propertyName: string, getter: Getter, setter?: Setter | boolean, enumerable = false, configurable = false) => {
if (typeof setter === 'boolean') {
+ console.log('Set `setter` to boolean is deprecated. Please don not use like this again.');
enumerable = setter;
setter = undefined;
}
@@ -132,12 +151,13 @@ export const getset = (() => {
})();
/**
- * @en
- * Define get accessor, just help to call Object.defineProperty(...).
- * @zh
- * 定义 get 访问器,帮助调用 Object.defineProperty()
- * @param [enumerable=false]
- * @param [configurable=false]
+ * @en A helper function to add or modify `get`, `enumerable` or `configurable` of a property.
+ * @zh 添加或修改属性的 `get`, `enumerable` 或者 `configurable`。
+ * @param object @en The object to add or modify attributes. @zh 要添加或者修改属性的对象。
+ * @param propertyName @en The property name to add or modify. @zh 要添加或修改的属性名。
+ * @param getter @en The getter of a property. @zh 属性的获取函数。
+ * @param enumerable @en If the property is enumerable. @zh 属性是否可列举。
+ * @param configurable @en If the property is configurable. @zh 属性是否可配置。
*/
export const get = (() => {
const descriptor: PropertyDescriptor = {
@@ -155,12 +175,13 @@ export const get = (() => {
})();
/**
- * @en
- * Define set accessor, just help to call Object.defineProperty(...)
- * @zh
- * 定义 set 访问器,帮助调用 Object.defineProperty
- * @param [enumerable=false]
- * @param [configurable=false]
+ * @en A helper function to add or modify `get`, `enumerable` or `configurable` of a property.
+ * @zh 添加或修改属性的 `get`, `enumerable` 或者 `configurable`。
+ * @param object @en The object to add or modify attributes. @zh 要添加或者修改属性的对象。
+ * @param propertyName @en The property name to add or modify. @zh 要添加或修改的属性名。
+ * @param setter @en The setter of a property. @zh 属性的设置函数。
+ * @param enumerable @en If the property is enumerable. @zh 属性是否可列举。
+ * @param configurable @en If the property is configurable. @zh 属性是否可配置。
*/
export const set = (() => {
const descriptor: PropertyDescriptor = {
@@ -187,9 +208,11 @@ export const set = (() => {
* `Object.create(null)` 用于创建无 prototype (也就无继承)的空对象。
* 这样我们在该对象上查找属性时,就不用进行 `hasOwnProperty` 判断,此时对性能提升有帮助。
*
- * @param [forceDictMode=false] Apply the delete operator to newly created map object.
- * This causes V8 to put the object in "dictionary mode" and disables creation of hidden classes
- * which are very expensive for objects that are constantly changing shape.
+ * @param forceDictMode @en Apply the delete operator to newly created map object. This will let V8 put the object in
+ * "dictionary mode" and disables creation of hidden classes. This will improve the performance of objects that are
+ * constantly changing shape.
+ * @zh 对新创建的地图对象应用删除操作。这将让V8将对象置于 "字典模式",并禁止创建隐藏类。这将提高那些不断变化形状对象的性能。
+ * @returns @en A newly map object. @zh 一个新的 map 对象。
*/
export function createMap (forceDictMode?: boolean): any {
const map = Object.create(null);
@@ -207,11 +230,13 @@ export function createMap (forceDictMode?: boolean): any {
/**
* @en
- * Get class name of the object, if object is just a {} (and which class named 'Object'), it will return "".
- * (modified from the code from this stackoverflow post)
+ * Gets class name of the object, if object is just a {} (and which class named 'Object'), it will return "".
+ * (modified from the code of stackoverflow post)
* @zh
- * 获取对象的类型名称,如果对象是 {} 字面量,将会返回 ""
- * @param objOrCtor instance or constructor
+ * 获取对象的类型名称,如果对象是 {} 字面量,将会返回 ""。参考了 stackoverflow 的代码实现:
+ * stackoverflow 的实现
+ * @param objOrCtor @en An object instance or constructor. @zh 类实例或者构造函数。
+ * @returns @en The class name. @zh 类名。
*/
export function getClassName (objOrCtor: any): string {
if (typeof objOrCtor === 'function') {
@@ -220,10 +245,10 @@ export function getClassName (objOrCtor: any): string {
if (prototype && prototype.hasOwnProperty(classNameTag) && prototype[classNameTag]) {
return prototype[classNameTag] as string;
}
- let retval = '';
+ let ret = '';
// for browsers which have name property in the constructor of the object, such as chrome
if (objOrCtor.name) {
- retval = objOrCtor.name;
+ ret = objOrCtor.name;
}
if (objOrCtor.toString) {
let arr;
@@ -238,10 +263,10 @@ export function getClassName (objOrCtor: any): string {
arr = /function\s*(\w+)/.exec(str);
}
if (arr && arr.length === 2) {
- retval = arr[1];
+ ret = arr[1];
}
}
- return retval !== 'Object' ? retval : '';
+ return ret !== 'Object' ? ret : '';
} else if (objOrCtor && objOrCtor.constructor) {
return getClassName(objOrCtor.constructor);
}
@@ -249,14 +274,16 @@ export function getClassName (objOrCtor: any): string {
}
/**
- * @en
- * Defines a polyfill field for obsoleted codes.
- * @zh
- * 为废弃代码定义一个填充字段
- * @param object - YourObject or YourClass.prototype
- * @param obsoleted - "OldParam" or "YourClass.OldParam"
- * @param newExpr - "NewParam" or "YourClass.NewParam"
- * @param [writable=false]
+ * @en Deprecates a property. It will print waring message if the deprecated property is accessed.
+ * The warning message includes new property name to use.
+ * @zh 废弃一个属性。如果被废弃属性还在使用的话,会打印警告消息。警告消息包含新的属性名。
+ * @param object @en The object or class of the property to deprecate.
+ * @zh 被废弃属性的对象或者类。
+ * @param obsoleted @en The property name to deprecate. It could be a property name or `className.propertyName`.
+ * @zh 要废弃的属性名。可以直接传属性名或者是 `类名.属性名` 的形式。
+ * @param newExpr @en New property name to use. It could be a property name or `className.propertyName`.
+ * @zh 新的属性名。可以直接传属性名或者是 `类名.属性名` 的形式。
+ * @param writable @en Whether the property is writable. Default is false. @zh 该属性是否可写。默认不可写。
*/
export function obsolete (object: any, obsoleted: string, newExpr: string, writable?: boolean) {
const extractPropName = /([^.]+)$/;
@@ -283,14 +310,15 @@ export function obsolete (object: any, obsoleted: string, newExpr: string, writa
}
/**
- * @en
- * Defines all polyfill fields for obsoleted codes corresponding to the enumerable properties of props.
- * @zh
- * 为所有可废弃属性定义填充字段
- * @param obj - YourObject or YourClass.prototype
- * @param objName - "YourObject" or "YourClass"
- * @param props
- * @param [writable=false]
+ * @en Deprecates some properties. It will print waring message if any deprecated property is accessed.
+ * The warning message includes new property name to use.
+ * @zh 废弃一组属性。如果被废弃属性还在使用的话,会打印警告消息。警告消息包含新的属性名。
+ * @param obj @en The object or class of these properties to deprecate.
+ * @zh 被废弃属性的对象或者类。
+ * @param objName @en The object name or class name of these properties to deprecate.
+ * @zh 被废弃属性的对象名或者类名。
+ * @param props @en The property names to deprecate. @zh 被废弃的一组属性名。
+ * @param writable @en Whether these properties are writable. @zh 被废弃的属性是否可写。
*/
export function obsoletes (obj, objName, props, writable) {
for (const obsoleted in props) {
@@ -306,10 +334,12 @@ const REGEXP_STR = /%s/;
* @en
* A string tool to construct a string with format string.
* @zh
- * 通过格式字符串构造一个字符串
- * @param msg - A JavaScript string containing zero or more substitution strings (%s).
- * @param subst - JavaScript objects with which to replace substitution strings within msg.
- * This gives you additional control over the format of the output.
+ * 根据格式字符串构造一个字符串。
+ * @param msg @en A JavaScript string containing zero or more substitution strings (%s).
+ * @zh 包含有 0 个或者多个格式符的字符串。
+ * @param subst @en JavaScript objects with which to replace substitution strings within msg.
+ * @zh 替换 `msg` 里格式符的表达式。
+ * @returns @en A new formatted string. @zh 格式化后的新字符串。
* @example
* ```
* import { js } from 'cc';
@@ -317,7 +347,7 @@ const REGEXP_STR = /%s/;
* js.formatStr(a, b, c);
* ```
*/
-export function formatStr (msg: string, ...subst: any[]) {
+export function formatStr (msg: string, ...subst: any[]): string {
if (arguments.length === 0) {
return '';
}
@@ -345,6 +375,11 @@ export function formatStr (msg: string, ...subst: any[]) {
}
// see https://github.com/petkaantonov/bluebird/issues/1389
+/**
+ * @en Removes the first argument. @zh 移除第一个参数。
+ * @returns @en An Array that contains all arguments except the first one.
+ * @zh 新的参数数组,该数组不包含第一个参数。
+ */
export function shiftArguments () {
const len = arguments.length - 1;
const args = new Array(len);
@@ -356,9 +391,15 @@ export function shiftArguments () {
}
/**
- * Get property descriptor in object and all its ancestors.
+ * @en Gets a property descriptor by property name of an object or its prototypes.
+ * @zh 根据属性名从一个对象或者它的原型链中获取属性描述符。
+ * @param object @en The object to get property descriptor. @zh 获取描述符的对象。
+ * @param propertyName @en The property name to get property descriptor.
+ * @zh 获取属性描述符的属性名。
+ * @returns @en A `PropertyDescriptor` instance or null if not found.
+ * @zh 属性描述符对象。如果没找到的话,返回 null。
*/
-export function getPropertyDescriptor (object: any, propertyName: string) {
+export function getPropertyDescriptor (object: any, propertyName: string): PropertyDescriptor | null {
while (object) {
const pd = Object.getOwnPropertyDescriptor(object, propertyName);
if (pd) {
@@ -369,13 +410,20 @@ export function getPropertyDescriptor (object: any, propertyName: string) {
return null;
}
-function _copyprop (name: string, source: any, target: any) {
+function _copyProp (name: string, source: any, target: any) {
const pd = getPropertyDescriptor(source, name);
if (pd) {
Object.defineProperty(target, name, pd);
}
}
+/**
+ * @en Copies all properties except those in `excepts` from `source` to `target`.
+ * @zh 把 `source` 的所有属性,除了那些定义在 `excepts`的属性,拷贝到 `target`。
+ * @param source @en Source object to copy from. @zh 拷贝的源对象。
+ * @param target @en Target object to copy to. @zh 拷贝到目标对象。
+ * @param excepts @en Properties are not copied. @zh 不拷贝到属性。
+ */
export function copyAllProperties (source: any, target: any, excepts: Array) {
const propertyNames: Array = Object.getOwnPropertyNames(source);
for (let i = 0, len = propertyNames.length; i < len; ++i) {
@@ -384,18 +432,17 @@ export function copyAllProperties (source: any, target: any, excepts: Array, ...sources: any[]) {
object = object || {};
@@ -407,7 +454,7 @@ export function addon (object?: Record, ...sources: any[])
}
for (const name in source) {
if (!(name in object)) {
- _copyprop(name, source, object);
+ _copyProp(name, source, object);
}
}
}
@@ -416,11 +463,12 @@ export function addon (object?: Record, ...sources: any[])
}
/**
- * @en
- * Copy all properties from arguments[1...n] to object.
- * @zh
- * 拷贝源对象所有属性到目标对象上,如果有属性冲突,则以源对象为准
- * @return The result object.
+ * @en Copies all the properties in "sources" from "sources" to "object".
+ * @zh 将 "sources" 中的所有属性从 "sources" 复制到 "object"。
+ * @param object @en Object to copy properties to. @zh 拷贝的目标对象。
+ * @param sources @en Source objects to copy properties from. @zh 拷贝到源对象数组。
+ * @return @en The passing `object` or a new object if passing object is not valid.
+ * @zh 传入的对象。如果传入的对象无效或者没传入,将返回一个新对象。
*/
export function mixin (object?: Record, ...sources: any[]) {
object = object || {};
@@ -431,7 +479,7 @@ export function mixin (object?: Record, ...sources: any[])
continue;
}
for (const name in source) {
- _copyprop(name, source, object);
+ _copyProp(name, source, object);
}
}
}
@@ -440,14 +488,12 @@ export function mixin (object?: Record, ...sources: any[])
/**
* @en
- * Derive the class from the supplied base class.
- * Both classes are just native javascript constructors, not created by `Class`, so
- * usually you will want to inherit using [[CCClass]] instead.
+ * Makes a class inherit from the supplied base class.
* @zh
- * 将一个类型继承另一个类型
- * 两个类型都需要是 javascript 的构建函数,而不是 `Class`, 所以你通常可以用 [[CCClass]] 来代替
- * @param base The baseclass to inherit.
- * @return The result class.
+ * 将一个类型继承另一个类型。
+ * @param cls @en The class to inherit. @zh 要继承的类。
+ * @param base @en The class to inherit from. @zh 被继承的类。
+ * @returns @en Passed in `cls`. @zh 传入的 `cls`。
*/
// eslint-disable-next-line @typescript-eslint/ban-types
export function extend (cls: Function, base: Function) {
@@ -478,15 +524,15 @@ export function extend (cls: Function, base: Function) {
}
/**
- * @en
- * Get super class.
- * @zh
- * 获取父类
- * @param constructor The constructor of subclass.
+ * @en Get super class.
+ * @zh 获取父类。
+ * @param constructor @en The constructor to get super class.
+ * @zh 要获取父类的构造函数。
+ * @returns @en Super class. @zh 父类。
*/
// eslint-disable-next-line @typescript-eslint/ban-types
export function getSuper (constructor: Function) {
- const proto = constructor.prototype; // binded function do not have prototype
+ const proto = constructor.prototype; // bound function do not have prototype
const dunderProto = proto && Object.getPrototypeOf(proto);
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return dunderProto && dunderProto.constructor;
@@ -494,12 +540,12 @@ export function getSuper (constructor: Function) {
/**
* @en
- * Checks whether subclass is child of superclass or equals to superclass.
- * @zh
- * 判断一类型是否是另一类型的子类或本身
- * @param subclass sub class to be checked
- * @param superclass super class to be checked
- * @return whether subclass is child of superclass
+ * Checks whether a class is child of another class, or is the same type as another class.
+ * @zh 判断一类型是否是另一类型的子类或本身。
+ * @param subclass @en Sub class to check. @zh 子类类型。
+ * @param superclass @en Super class to check. @zh 父类类型。
+ * @return @en True if sub class is child of super class, or they are the same type. False else.
+ * @zh 如果子类类型是父类类型的子类,或者二者是相同类型,那么返回 true,否则返回 false。
*/
export function isChildClassOf(subclass: unknown, superclass: T): subclass is T;
export function isChildClassOf(subclass: unknown, superclass: unknown): boolean;
@@ -532,10 +578,10 @@ export function isChildClassOf (subclass: unknown, superclass: unknown) {
}
/**
- * @en
- * Removes all enumerable properties from object.
- * @zh
- * 移除对象中所有可枚举属性
+ * @en Removes all enumerable properties from a object.
+ * @zh 移除对象中所有可枚举属性.
+ * @param object @en The object to remove enumerable properties from.
+ * @zh 要删除可枚举属性的对象。
*/
export function clear (object: Record) {
for (const key of Object.keys(object)) {
@@ -602,13 +648,10 @@ export const _setClassId = setup('__cid__', _idToClass, false);
const doSetClassName = setup('__classname__', _nameToClass, true);
/**
- * @en
- * Register the class by specified name manually
- * @zh
- * 通过指定的名称手动注册类型
- * @method setClassName
- * @param className
- * @param constructor
+ * @en Registers a class by specified name manually.
+ * @zh 通过指定的名称手动注册类型
+ * @param className @en Class name to register. @zh 注册的类名。
+ * @param constructor @en Constructor to register. @zh 注册的构造函数。
*/
export function setClassName (className: string, constructor: Constructor) {
doSetClassName(className, constructor);
@@ -623,17 +666,16 @@ export function setClassName (className: string, constructor: Constructor) {
}
/**
- * @en Set an alias name for class.
- * If `setClassAlias(target, alias)`, `alias` will be a single way short cut for class `target`.
- * If you try `js.getClassByName(alias)`, you will get target.
- * But `js.getClassName(target)` will return the original name of `target`, not the alias.
- * @zh 为类设置别名。
- * 当 `setClassAlias(target, alias)` 后,
- * `alias` 将作为类 `target`的“单向 ID” 和“单向名称”。
- * 因此,`getClassById(alias)` 和 `getClassByName(alias)` 都会得到 `target`。
- * 这种映射是单向的,意味着 `getClassName(target)` 和 `getClassId(target)` 将不会是 `alias`。
- * @param target Constructor of target class.
- * @param alias Alias to set. The name shall not have been set as class name or alias of another class.
+ * @en Sets an alias for a class.
+ * After executing `setClassAlias(target, alias)`, `alias` will be a single way short cut for class `target`.
+ * `js.getClassByName(alias)` and `getClassById(alias)` will return `target`. But `js.getClassName(target)`
+ * will return the original class name of `target`, not the alias.
+ * @zh 为类设置别名。执行 `setClassAlias(target, alias)` 后,`alias` 将作为类 `target` 的 “单向 ID” 和 “单向名称”。
+ * 因此,`getClassById(alias)` 和 `getClassByName(alias)` 都会得到 `target`。这种映射是单向的,这意味着 `getClassName(target)`
+ * 和 `getClassId(target)` 将不会返回 `alias`。
+ * @param target @en Constructor of a class to set an alias. @zh 设置别名的类的构造函数。
+ * @param alias @en Alias to set. The name shall not have been set as class name or alias of another class.
+ * @zh 类的别名。别名不能重复,也不能是已有类的名字。
*/
export function setClassAlias (target: Constructor, alias: string) {
const nameRegistry = _nameToClass[alias];
@@ -661,15 +703,14 @@ export function setClassAlias (target: Constructor, alias: string) {
/**
* @en
- * Unregister a class from cocos.
- *
- * If you dont need a registered class anymore, you should unregister the class so that cocos will not keep its reference anymore.
- * Please note that its still your responsibility to free other references to the class.
+ * Unregister some classes from engine.
+ * If you don't need a registered class anymore, you should unregister the class or engine will keep its reference.
+ * Please note that it‘s your responsibility to remove other references to the class.
* @zh
- * 取消注册类型,如果你不再需要一个注册的类,你应该取消注册这个类,这样 cocos 就不会再保留它的引用。
- * 请注意,你仍然有责任释放对该类的其他引用。
+ * 取消注册类型。如果你不再需要一个注册的类,你应该取消注册这个类,否则引擎会还有对它的引用。
+ * 请注意,你仍然有责任释放其他地方对该类的引用。
*
- * @param ...constructor - the class you will want to unregister, any number of classes can be added
+ * @param ...constructor @en The classes to unregister. @zh 取消注册的类型列表。
*/
// eslint-disable-next-line @typescript-eslint/ban-types
export function unregisterClass (...constructors: Function[]) {
@@ -695,25 +736,22 @@ export function unregisterClass (...constructors: Function[]) {
}
/**
- * @en
- * Get the registered class by id
- * @zh
- * 通过 id 获取已注册的类型
- * @param classId
+ * @en Gets a registered class by id.
+ * @zh 通过 id 获取已注册的类型。
+ * @param classId @en An id to get class.
* @return constructor
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
+ * Please use `getClassById()` instead.
*/
export function _getClassById (classId) {
return getClassById(classId);
}
/**
- * @en
- * Get the registered class by id
- * @zh
- * 通过 id 获取已注册的类型
- * @param classId
- * @return constructor
+ * @en Gets the registered class by id.
+ * @zh 通过 id 获取已注册的类型。
+ * @param classId @en The class id used to get class. @zh 获取类的 id。
+ * @returns @en The constructor of the registered class. @zh 注册的类构造函数。
*/
export function getClassById (classId) {
return _idToClass[classId];
@@ -721,11 +759,11 @@ export function getClassById (classId) {
/**
* @en
- * Get the registered class by name
+ * Gets the registered class by class name.
* @zh
- * 通过名字获取已注册的类型
- * @param classname
- * @return constructor of the class
+ * 通过类名获取已注册的类型。
+ * @param classname @en The class name used to get class. @zh 获取类的类名。
+ * @returns @en The constructor of the registered class. @zh 注册的类构造函数。
*/
export function getClassByName (classname) {
return _nameToClass[classname];
@@ -739,7 +777,8 @@ export function getClassByName (classname) {
* @param obj - instance or constructor
* @param [allowTempId = true] - can return temp id in editor
* @return
- * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
+ * @deprecated since v3.5.0. this is an engine private interface that will be removed in the future.
+ * Please use `getClassId()` instead.
*/
export function _getClassId (obj, allowTempId?: boolean) {
return getClassId(obj, allowTempId);
@@ -747,12 +786,14 @@ export function _getClassId (obj, allowTempId?: boolean) {
/**
* @en
- * Get class id of the object
+ * Gets class id of an object
* @zh
- * 获取对象的 class id
- * @param obj - instance or constructor
- * @param [allowTempId = true] - can return temp id in editor
- * @return
+ * 获取对象的 class id。
+ * @param obj @en An object instance to get class id. @zh 获取类标识的对象。
+ * @param allowTempId @en Whether allow to return a temple class id in editor.
+ * @zh 在编辑器时,是否允许返回一个临时的类标识。
+ * @returns @en Class id if found, empty string else.
+ * @zh 找到的类标识。如果没找到的话,返回空字符串。
*/
export function getClassId (obj, allowTempId?: boolean) {
allowTempId = (typeof allowTempId !== 'undefined' ? allowTempId : true);
diff --git a/cocos/core/utils/misc.ts b/cocos/core/utils/misc.ts
index 40f35df602..7648639fdd 100644
--- a/cocos/core/utils/misc.ts
+++ b/cocos/core/utils/misc.ts
@@ -25,7 +25,7 @@
/* eslint-disable no-new-func */
-import { EDITOR, DEV } from 'internal:constants';
+import { DEV } from 'internal:constants';
import { getClassName, getset, isEmptyObject } from './js';
import { legacyCC } from '../global-exports';
import { warnID } from '../platform/debug';
@@ -34,7 +34,7 @@ import { macro } from '../platform/macro';
export const BUILTIN_CLASSID_RE = /^(?:cc|dragonBones|sp|ccsg)\..+/;
const BASE64_KEYS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
-const values:number[] = new Array(123); // max char code in base64Keys
+const values: number[] = new Array(123); // max char code in base64Keys
for (let i = 0; i < 123; ++i) { values[i] = 64; } // fill with placeholder('=') index
for (let i = 0; i < 64; ++i) { values[BASE64_KEYS.charCodeAt(i)] = i; }
@@ -42,10 +42,13 @@ for (let i = 0; i < 64; ++i) { values[BASE64_KEYS.charCodeAt(i)] = i; }
export const BASE64_VALUES = values;
/**
+ * @en Defines properties for a class, or replaces getter, setter of existing properties.
+ * @param ctor @en Class to modify.
+ * @param sameNameGetSets @en Getters and setters of properties. The getter and setter
+ * have the same name. So a property getter and setter occupy one position in `sameNameGetSets`.
+ * @param diffNameGetSets @en Getters and setters of properties. The getter and setter
+ * have different names. So a property getter and setter occupy two positions in `diffNameGetSets`.
* @engineInternal
- * @param ctor
- * @param sameNameGetSets
- * @param diffNameGetSets
*/
export function propertyDefine (ctor, sameNameGetSets, diffNameGetSets) {
function define (np, propName, getter, setter) {
@@ -77,7 +80,15 @@ export function propertyDefine (ctor, sameNameGetSets, diffNameGetSets) {
}
}
-// set value to map, if key exists, push to array
+/**
+ * @en Inserts a new element into a map. All values corresponding to the same key are stored in an array.
+ * @zh 往 map 插入一个元素。同一个关键字对应的所有值存储在一个数组里。
+ * @param map @en The map to insert element. @zh 插入元素的 map。
+ * @param key @en The key of new element. @zh 新插入元素的关键字。
+ * @param value @en The value of new element. @zh 新插入元素的值。
+ * @param pushFront @en Whether to put new value in front of the vector if key exists.
+ * @zh 如果关键字已经存在,是否把新插入的值放到数组第一个位置。
+ */
export function pushToMap (map, key, value, pushFront) {
const exists = map[key];
if (exists) {
@@ -96,6 +107,15 @@ export function pushToMap (map, key, value, pushFront) {
}
}
+/**
+ * @en Checks whether a node is a descendant of a given node, that is the node itself, one of its direct
+ * children (childNodes), one of the children's direct children, and so on.
+ * @zh 检查节点是否是一个给定的节点的后代,即节点本身、它的一个直接子节点(childNodes)、该子节点的一个直接子节点,依此类推。
+ * @param refNode @en The node to check. @zh 检查的节点。
+ * @param otherNode @en The node to test with. @zh 用来测试的节点。
+ * @returns @en True if otherNode is contained in refNode, false if not.
+ * @zh 如果 refNode 包含 otherNode,返回 true;否则返回 false。
+ */
export function contains (refNode, otherNode) {
if (typeof refNode.contains === 'function') {
return refNode.contains(otherNode) as boolean;
@@ -116,19 +136,31 @@ export function contains (refNode, otherNode) {
}
}
-export function isDomNode (obj) {
+/**
+ * @en Checks whether a node is a DOM node. @zh 检查一个节点是否是一个 DOM 节点。
+ * @param node @en The node the check. @zh 被检查节点。
+ * @returns @en True if node is a DOM node, false else.
+ * @zh 如果 DOM 节点,返回 true;否则返回 false。
+ */
+export function isDomNode (node) {
if (typeof window === 'object' && typeof Node === 'function') {
// If "TypeError: Right-hand side of 'instanceof' is not callback" is thrown,
// it should because window.Node was overwritten.
- return obj instanceof Node;
+ return node instanceof Node;
} else {
- return !!obj
- && typeof obj === 'object'
- && typeof obj.nodeType === 'number'
- && typeof obj.nodeName === 'string';
+ return !!node
+ && typeof node === 'object'
+ && typeof node.nodeType === 'number'
+ && typeof node.nodeName === 'string';
}
}
+/**
+ * @en Invoke a function in next frame. @zh 在下一帧执行传入的函数。
+ * @param callback @en The function to be invoked next frame. @zh 下一帧要执行的函数。
+ * @param p1 @en The first parameter passed to `callback`. @zh 传给回调函数的第一个参数。
+ * @param p2 @en The seconde parameter passed to `callback`. @zh 传给回调函数的第二个参数。
+ */
export function callInNextTick (callback, p1?: any, p2?: any) {
if (callback) {
setTimeout(() => {
@@ -138,6 +170,14 @@ export function callInNextTick (callback, p1?: any, p2?: any) {
}
// use anonymous function here to ensure it will not being hoisted without EDITOR
+/**
+ * @en Create a new function that will invoke `functionName` with try catch.
+ * @zh 创建一个新函数,该函数会使用 try catch 机制调用 `functionName`.
+ * @param funcName @en The function name to be invoked with try catch.
+ * @zh 被 try catch 包裹的函数名。
+ * @returns @en A new function that will invoke `functionName` with try catch.
+ * @zh 使用 try catch 机制调用 `functionName` 的新函数.
+ */
export function tryCatchFunctor_EDITOR (funcName) {
// eslint-disable-next-line @typescript-eslint/no-implied-eval
return Function('target',
@@ -149,6 +189,13 @@ export function tryCatchFunctor_EDITOR (funcName) {
+ `}`);
}
+/**
+ * @en Checks whether an object is an empty object.
+ * @zh 检查一个对象是否为空对象。
+ * @param obj @en The object to check. @zh 要检查的对象。
+ * @returns @en True if it is an empty object. False if it is not an empty object, not Object type, null or undefined.
+ * @ 如果是空对象,返回 true。如果不是空对象,不是Object类型,空或未定义,则为假。
+ */
export function isPlainEmptyObj_DEV (obj) {
if (!obj || obj.constructor !== Object) {
return false;
@@ -157,18 +204,18 @@ export function isPlainEmptyObj_DEV (obj) {
}
/**
- * @en Clamp a value between from and to.
- * if the original value is larger than max_inclusive, return max_inclusive.
- * if the original value is smaller than min_inclusive, return min_inclusive.
- * else return the original value.
+ * @en Clamps a value between a min and a max value.
+ * If the original value is greater than max_inclusive, returns max_inclusive.
+ * If the original value is less than min_inclusive, returns min_inclusive.
+ * Else returns the original value.
* @zh 限定浮点数的最大最小值。
- * 数值大于 max_inclusive 则返回 max_inclusive。
- * 数值小于 min_inclusive 则返回 min_inclusive。
+ * 如果数值大于 max_inclusive 则返回 max_inclusive。
+ * 如果数值小于 min_inclusive 则返回 min_inclusive。
* 否则返回自身。
- * @param value @en Original value @zh 初始值
- * @param min_inclusive @en Minimum value in between @zh 最小值
- * @param max_inclusive @en Maximum value in between @zh 最大值
- * @return {Number} @en The value clamped @zh 目标值
+ * @param value @en Original value. @zh 初始值。
+ * @param min_inclusive @en Minimum value in range. @zh 最小值。
+ * @param max_inclusive @en Maximum value in range. @zh 最大值。
+ * @returns @en The clamped value. @zh 目标值。
* @example
* var v1 = clampf(20, 0, 20); // 20;
* var v2 = clampf(-1, 0, 20); // 0;
@@ -184,20 +231,20 @@ export function clampf (value: number, min_inclusive: number, max_inclusive: num
}
/**
- * @en converts degrees to radians
- * @zh 角度转弧度
- * @param angle @en The degree to convert @zh 角度
- * @return {Number} The radian. @zh 弧度
+ * @en Converts degree to radian.
+ * @zh 将度数转换为弧度。
+ * @param angle @en The degree to convert. @zh 角度。
+ * @returns @en The radian. @zh 弧度。
*/
export function degreesToRadians (angle: number) {
return angle * macro.RAD;
}
/**
- * @en converts radians to degrees
- * @zh 弧度转角度
- * @param angle @en The radian to convert @zh 弧度
- * @return {Number} @en The degree @zh 角度
+ * @en Converts radian to degree.
+ * @zh 将弧度转换为角度。
+ * @param angle @en The radian to convert. @zh 弧度。
+ * @returns @en The degree. @zh 角度。
*/
export function radiansToDegrees (angle) {
return angle * macro.DEG;
diff --git a/cocos/core/utils/path.ts b/cocos/core/utils/path.ts
index 1c5dbe53f2..964a33d021 100644
--- a/cocos/core/utils/path.ts
+++ b/cocos/core/utils/path.ts
@@ -31,11 +31,13 @@ const DIRNAME_RE = /((.*)(\/|\\|\\\\))?(.*?\..*$)?/;
const NORMALIZE_RE = /[^\.\/]+\/\.\.\//;
/**
- * @en Join strings to be a path.
+ * @en Joins strings to be a path.
* @zh 拼接字符串为路径。
+ * @param segments @en Strings to be joined. @zh 被拼接的字符串数组。
+ * @returns @en The final path. @zh 拼接后的路径。
* @example {@link cocos/core/utils/CCPath/join.js}
*/
-export function join (...segments: string[]) {
+export function join (...segments: string[]): string {
let result = '';
for (const segment of segments) {
result = (result + (result === '' ? '' : '/') + segment).replace(/(\/|\\\\)$/, '');
@@ -44,21 +46,23 @@ export function join (...segments: string[]) {
}
/**
- * @en Get the ext name of a path including '.', like '.png'.
+ * @en Gets the extension name of a path including '.', like '.png'.
* @zh 返回 Path 的扩展名,包括 '.',例如 '.png'。
+ * @param path @en A file path. @zh 文件路径。
+ * @returns @en The extension name. @zh 扩展名。
* @example {@link cocos/core/utils/CCPath/extname.js}
*/
-export function extname (path: string) {
+export function extname (path: string): string {
const temp = EXTNAME_RE.exec(path);
return temp ? temp[1] : '';
}
/**
- * @en Get the main name of a file name.
+ * @en Gets the main name of a file name, exclude extension name.
* @zh 获取文件名的主名称。
* @deprecated
*/
-export function mainFileName (fileName: string) {
+export function mainFileName (fileName: string): string {
if (fileName) {
const idx = fileName.lastIndexOf('.');
if (idx !== -1) {
@@ -69,8 +73,11 @@ export function mainFileName (fileName: string) {
}
/**
- * @en Get the file name of a file path.
- * @zh 获取文件路径的文件名。
+ * @en Gets the file name of a file path, exclude extension name and directory name.
+ * @zh 获取文件路径的文件名,不包含扩展名和目录名。
+ * @param path @en A file path. @zh 文件路径。
+ * @param extName @en File extension name. @zh 文件扩展名。
+ * @returns @en The file name. @zh 文件名。
* @example {@link cocos/core/utils/CCPath/basename.js}
*/
export function basename (path: string, extName?: string) {
@@ -91,21 +98,26 @@ export function basename (path: string, extName?: string) {
}
/**
- * @en Get dirname of a file path.
+ * @en Gets directory name of a file path.
* @zh 获取文件路径的目录名。
+ * @param path @en A file path. @zh 文件路径。
+ * @returns @en Directory name. @zh 文件目录名。
* @example {@link cocos/core/utils/CCPath/dirname.js}
*/
-export function dirname (path: string) {
+export function dirname (path: string): string {
const temp = DIRNAME_RE.exec(path);
return temp ? temp[2] : '';
}
/**
- * @en Change extname of a file path.
- * @zh 更改文件路径的扩展名。
+ * @en Changes file extension name.
+ * @zh 更改文件的扩展名。
+ * @param path @en A file path. @zh 文件路径。
+ * @param extName @en New file extension name. @zh 新文件扩展名。
+ * @returns @en New file path. @zh 新的文件路径。
* @example {@link cocos/core/utils/CCPath/changeExtname.js}
*/
-export function changeExtname (path: string, extName?: string) {
+export function changeExtname (path: string, extName?: string): string {
extName = extName || '';
let index = path.indexOf('?');
let tempStr = '';
@@ -121,24 +133,28 @@ export function changeExtname (path: string, extName?: string) {
}
/**
- * @en Change file name of a file path.
+ * @en Changes file name of a file path.
* @zh 更改文件路径的文件名。
+ * @param path @en A file path. @zh 文件路径。
+ * @param newBaseName @en New file name. @zh 新文件名。
+ * @param keepExt @en Whether to keep extension name. @zh 是否保留扩展名。
+ * @returns @en New file path. @zh 新文件路径。
* @example {@link cocos/core/utils/CCPath/changeBasename.js}
*/
-export function changeBasename (path: string, baseName: string, isSameExt?: boolean) {
- if (baseName.indexOf('.') === 0) {
- return changeExtname(path, baseName);
+export function changeBasename (path: string, newBaseName: string, keepExt?: boolean): string {
+ if (newBaseName.indexOf('.') === 0) {
+ return changeExtname(path, newBaseName);
}
let index = path.indexOf('?');
let tempStr = '';
- const ext = isSameExt ? extname(path) : '';
+ const ext = keepExt ? extname(path) : '';
if (index > 0) {
tempStr = path.substring(index);
path = path.substring(0, index);
}
index = path.lastIndexOf('/');
index = index <= 0 ? 0 : index + 1;
- return path.substring(0, index) + baseName + ext + tempStr;
+ return path.substring(0, index) + newBaseName + ext + tempStr;
}
// todo make public after verification
@@ -153,10 +169,23 @@ export function _normalize (url) {
return url;
}
+/**
+ * @en Removes the last path separator('/' or '\') of a path if exist.
+ * @zh 如果存在的话,删除文件路径的最后一个分隔符('/' 或者 '\')。
+ * @param path @en A file path to modify. @zh 要修改的文件路径。
+ * @returns @en A new file path without last file separator.
+ * @zh 路径最后分隔符的新路径。
+ */
export function stripSep (path: string) {
return path.replace(/[\/\\]$/, '');
}
+/**
+ * @en Gets file separator for different platforms. It is `/` on unix like platforms,
+ * and `\` on windows.
+ * @zh 获取不同平台的文件分割符。类 unix 系统是 `/`,windows 系统是 `\`。
+ * @returns @en File separator. @zh 文件分割符。
+ */
export function getSeperator () {
return systemInfo.os === OS.WINDOWS ? '\\' : '/';
}
diff --git a/cocos/core/utils/pool.ts b/cocos/core/utils/pool.ts
index 4468387633..a0c8d71df4 100644
--- a/cocos/core/utils/pool.ts
+++ b/cocos/core/utils/pool.ts
@@ -27,8 +27,8 @@ type CleanUpFunction = (value: T) => boolean | void;
/**
* @en
* A fixed-length object pool designed for general type.
- * The implementation of this object pool is very simple,
- * it can helps you to improve your game performance for objects which need frequent release and recreate operations
+ * The implementation of this object pool is very simple.
+ * It can help you to improve your game performance for objects which need frequent release and recreate operations.
* @zh
* 长度固定的对象缓存池,可以用来缓存各种对象类型。
* 这个对象池的实现非常精简,它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁。
@@ -79,7 +79,7 @@ type CleanUpFunction = (value: T) => boolean | void;
export class Pool {
/**
* @en
- * The current number of available objects, the default is 0, it will gradually increase with the recycle of the object,
+ * The current number of available objects, the default is 0. It will gradually increase with the recycle of the object,
* the maximum will not exceed the size specified when the constructor is called.
* @zh
* 当前可用对象数量,一开始默认是 0,随着对象的回收会逐渐增大,最大不会超过调用构造函数时指定的 size。
@@ -89,12 +89,12 @@ export class Pool {
/**
* @en
- * Get and initialize an object from pool. This method defaults to null and requires the user to implement it.
- * @zh
- * 获取并初始化对象池中的对象。这个方法默认为空,需要用户自己实现。
- * @param args - parameters to used to initialize the object
+ * Gets an object from pool.
+ * @zh 从对象池中获取一个对象。
+ * @returns @en An object or null if this pool doesn't contain any object.
+ * @zh 获取的对象。如果对象池中没有对象,返回 null。
*/
- public get () {
+ public get (): T | null {
return this._get();
}
@@ -102,23 +102,26 @@ export class Pool {
private _cleanup: CleanUpFunction | null;
/**
- * 使用构造函数来创建一个指定对象类型的对象池,您可以传递一个回调函数,用于处理对象回收时的清理逻辑。
- * @method constructor
- * @param {Function} [cleanupFunc] - the callback method used to process the cleanup logic when the object is recycled.
- * @param {Object} cleanupFunc.obj
- * @param {Number} size - initializes the length of the array
+ * @en Constructor. @zh 构造函数。
+ * @param cleanupFunc @en Callback method used to process the cleanup logic when the object is recycled.
+ * @zh 当对象放入对象池时,用来执行清理逻辑的回调函数。
+ * @param size @en Pool size. @zh 对象池大小。
*/
constructor (cleanup: CleanUpFunction, size: number);
/**
- * 使用构造函数来创建一个指定对象类型的对象池,您可以传递一个回调函数,用于处理对象回收时的清理逻辑。
- * @method constructor
- * @param {Function} [cleanupFunc] - the callback method used to process the cleanup logic when the object is recycled.
- * @param {Object} cleanupFunc.obj
- * @param {Number} size - initializes the length of the array
+ * @en Constructor. @zh 构造函数。
+ * @param size @en Pool size. @zh 对象池大小。
*/
constructor (size: number);
+ /**
+ * @en Constructor. @zh 构造函数。
+ * @param _0 @en If it is a number, it is the array size. Or it is a callback function used to process
+ * the cleanup logic when the object is recycled.
+ * @zh 如果是 number,那么它是对象池大小。否则是当对象放入对象池时,用来执行清理逻辑的回调函数。
+ * @param _1 @en Array size if it is a valid number. @zh 如果是个有效的 number 类型,那么是对象池大小。
+ */
constructor (_0: CleanUpFunction | number, _1?: number) {
const size = (_1 === undefined) ? (_0 as number) : _1;
const cleanupFunc = (_1 === undefined) ? null : (_0 as CleanUpFunction);
@@ -129,10 +132,10 @@ export class Pool {
/**
* @en
- * Get an object from pool, if no available object in the pool, null will be returned.
- * @zh
- * 获取对象池中的对象,如果对象池没有可用对象,则返回空。
- *
+ * Gets an object from pool.
+ * @zh 从对象池中获取一个对象。
+ * @returns @en An object or null if this pool doesn't contain any object.
+ * @zh 获取的对象。如果对象池中没有对象,返回 null。
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
*/
public _get () {
@@ -163,6 +166,8 @@ export class Pool {
/**
* @en Resize the pool.
* @zh 设置对象池容量。
+ * @param length @en New pool size.
+ * @zh 新对象池大小。
*/
public resize (length: number) {
if (length >= 0) {
diff --git a/cocos/core/utils/x-deprecated.ts b/cocos/core/utils/x-deprecated.ts
index e70e168016..91f37e3452 100644
--- a/cocos/core/utils/x-deprecated.ts
+++ b/cocos/core/utils/x-deprecated.ts
@@ -42,41 +42,41 @@ export function setDefaultLogTimes (times: number): void {
}
interface IReplacement {
- /** 废弃属性的名称 */
+ /** Deprecated property name. */
name: string;
- /** 警告的次数 */
+ /** Times to print log when accessing deprecated property. */
logTimes?: number;
- /** 替换属性的名称 */
+ /** New property name. */
newName?: string;
- /** 废弃属性的所属对象 */
+ /** The object to deprecate this property. */
target?: object;
- /** 废弃属性的所属对象的名称 */
+ /** The name of the object to deprecate this property. */
targetName?: string;
- /** 自定义替换属性(函数) */
+ /** New function to access the property. If it is valid, `customSetter` and `customGetter` will be ignored. */
customFunction?: Function;
- /** 自定义替换属性的 setter */
+ /** New setter. */
customSetter?: (v: any) => void;
- /** 自定义替换属性的 getter */
+ /** New getter. */
customGetter?: () => any;
- /** 额外建议 */
+ /** Property description used in warning log. */
suggest?: string;
}
interface IRemoveItem {
- /** 废弃属性的名称 */
+ /** Removed property name. */
name: string;
- /** 警告的次数 */
+ /** Times to print log when accessing removed property. */
logTimes?: number;
- /** 额外建议 */
+ /** Property description used in warning log. */
suggest?: string;
}
interface IMarkItem {
- /** 废弃属性的名称 */
+ /** Deprecated property name. */
name: string;
- /** 警告的次数 */
+ /** Times to print log when accessing deprecated property. */
logTimes?: number;
- /** 额外建议 */
+ /** Property description used in warning log. */
suggest?: string;
}
diff --git a/native/cocos/2d/renderer/Batcher2d.cpp b/native/cocos/2d/renderer/Batcher2d.cpp
index 9eecfc6c11..3625d4ad68 100644
--- a/native/cocos/2d/renderer/Batcher2d.cpp
+++ b/native/cocos/2d/renderer/Batcher2d.cpp
@@ -100,7 +100,7 @@ void Batcher2d::fillBuffersAndMergeBatches() {
walk(rootNode, 1);
generateBatch(_currEntity, _currDrawInfo);
- auto *scene = rootNode->getScene()->getRenderScene();
+ auto* scene = rootNode->getScene()->getRenderScene();
size_t const count = _batches.size();
for (size_t i = index; i < count; i++) {
scene->addBatch(_batches.at(i));
@@ -274,11 +274,7 @@ CC_FORCE_INLINE void Batcher2d::handleMiddlewareDraw(RenderEntity* entity, Rende
// check for merge draw
auto enableBatch = !entity->getUseLocal();
- if (enableBatch && _currTexture == texture && _currMeshBuffer == meshBuffer
- && !_currEntity->getUseLocal()
- && material->getHash() == _currMaterial->getHash()
- && drawInfo->getIndexOffset() == _currDrawInfo->getIndexOffset() + _currDrawInfo->getIbCount()
- && layer == _currLayer) {
+ if (enableBatch && _currTexture == texture && _currMeshBuffer == meshBuffer && !_currEntity->getUseLocal() && material->getHash() == _currMaterial->getHash() && drawInfo->getIndexOffset() == _currDrawInfo->getIndexOffset() + _currDrawInfo->getIbCount() && layer == _currLayer) {
auto ibCount = _currDrawInfo->getIbCount();
_currDrawInfo->setIbCount(ibCount + drawInfo->getIbCount());
} else {
diff --git a/native/cocos/2d/renderer/UIMeshBuffer.cpp b/native/cocos/2d/renderer/UIMeshBuffer.cpp
index 71d45c9ec2..6f539c46e2 100644
--- a/native/cocos/2d/renderer/UIMeshBuffer.cpp
+++ b/native/cocos/2d/renderer/UIMeshBuffer.cpp
@@ -48,7 +48,7 @@ void UIMeshBuffer::setIData(uint16_t* iData) {
_iData = iData;
}
-void UIMeshBuffer::initialize(ccstd::vector &&attrs, bool needCreateLayout) {
+void UIMeshBuffer::initialize(ccstd::vector&& attrs, bool needCreateLayout) {
_attributes = attrs;
_vertexFormatBytes = getAttributesStride(attrs);
if (needCreateLayout) {
diff --git a/native/cocos/3d/assets/MorphRendering.cpp b/native/cocos/3d/assets/MorphRendering.cpp
index 54c1fd0976..43bbdd7402 100644
--- a/native/cocos/3d/assets/MorphRendering.cpp
+++ b/native/cocos/3d/assets/MorphRendering.cpp
@@ -257,7 +257,7 @@ Vec4TextureFactory createVec4TextureFactory(gfx::Device *gfxDevice, uint32_t vec
uint32_t width = 0;
uint32_t height = 0;
bestSizeToHavePixels(pixelRequired, &width, &height);
- CC_ASSERT_GE(width * height , pixelRequired);
+ CC_ASSERT_GE(width * height, pixelRequired);
Vec4TextureFactory ret;
ret.width = width;
diff --git a/native/cocos/application/BaseGame.cpp b/native/cocos/application/BaseGame.cpp
index b1f2223c80..fa7ee208c6 100644
--- a/native/cocos/application/BaseGame.cpp
+++ b/native/cocos/application/BaseGame.cpp
@@ -49,13 +49,13 @@ int BaseGame::init() {
std::call_once(_windowCreateFlag, [&]() {
ISystemWindowInfo info;
info.title = _windowInfo.title;
-#if CC_PLATFORM == CC_PLATFORM_WINDOWS
+ #if CC_PLATFORM == CC_PLATFORM_WINDOWS
info.x = _windowInfo.x == -1 ? 50 : _windowInfo.x; // 50 meams move window a little for now
info.y = _windowInfo.y == -1 ? 50 : _windowInfo.y; // same above
-#else
+ #else
info.x = _windowInfo.x == -1 ? 0 : _windowInfo.x;
info.y = _windowInfo.y == -1 ? 0 : _windowInfo.y;
-#endif
+ #endif
info.width = _windowInfo.width;
info.height = _windowInfo.height;
info.flags = _windowInfo.flags;
diff --git a/native/cocos/audio/android/AssetFd.cpp b/native/cocos/audio/android/AssetFd.cpp
index 95dfe0968f..7011be2687 100644
--- a/native/cocos/audio/android/AssetFd.cpp
+++ b/native/cocos/audio/android/AssetFd.cpp
@@ -25,8 +25,8 @@
#define LOG_TAG "AssetFd"
-#include "audio/android/cutils/log.h"
#include "audio/android/AssetFd.h"
+#include "audio/android/cutils/log.h"
namespace cc {
diff --git a/native/cocos/audio/android/PcmAudioService.h b/native/cocos/audio/android/PcmAudioService.h
index f4ca07bebd..90a8a8e650 100644
--- a/native/cocos/audio/android/PcmAudioService.h
+++ b/native/cocos/audio/android/PcmAudioService.h
@@ -29,8 +29,8 @@
#include "audio/android/OpenSLHelper.h"
#include "audio/android/PcmData.h"
-#include
#include
+#include
namespace cc {
diff --git a/native/cocos/audio/android/Track.cpp b/native/cocos/audio/android/Track.cpp
index 5b3526cf24..9014ae7ace 100644
--- a/native/cocos/audio/android/Track.cpp
+++ b/native/cocos/audio/android/Track.cpp
@@ -25,8 +25,8 @@
#define LOG_TAG "Track"
-#include "audio/android/cutils/log.h"
#include "audio/android/Track.h"
+#include "audio/android/cutils/log.h"
#include
diff --git a/native/cocos/audio/android/Track.h b/native/cocos/audio/android/Track.h
index 3fcec2cd16..9b3c0b8125 100644
--- a/native/cocos/audio/android/Track.h
+++ b/native/cocos/audio/android/Track.h
@@ -25,9 +25,9 @@
#pragma once
-#include "audio/android/PcmData.h"
#include "audio/android/IVolumeProvider.h"
#include "audio/android/PcmBufferProvider.h"
+#include "audio/android/PcmData.h"
#include
#include
diff --git a/native/cocos/audio/android/audio.h b/native/cocos/audio/android/audio.h
index a4edecbc63..c790eca215 100644
--- a/native/cocos/audio/android/audio.h
+++ b/native/cocos/audio/android/audio.h
@@ -27,8 +27,8 @@
// ----------------------------------------------------------------------------
-#include
#include
+#include
#include "audio/android/cutils/bitops.h"
#define PROPERTY_VALUE_MAX 256
diff --git a/native/cocos/audio/android/utils/Utils.cpp b/native/cocos/audio/android/utils/Utils.cpp
index 339dbb6bc2..378ecc400a 100644
--- a/native/cocos/audio/android/utils/Utils.cpp
+++ b/native/cocos/audio/android/utils/Utils.cpp
@@ -23,8 +23,8 @@
THE SOFTWARE.
****************************************************************************/
#include "audio/android/utils/Utils.h"
-#include "platform/BasePlatform.h"
#include
+#include "platform/BasePlatform.h"
namespace cc {
diff --git a/native/cocos/audio/common/decoder/AudioDecoderWav.cpp b/native/cocos/audio/common/decoder/AudioDecoderWav.cpp
index 0664d92512..6487f330ef 100644
--- a/native/cocos/audio/common/decoder/AudioDecoderWav.cpp
+++ b/native/cocos/audio/common/decoder/AudioDecoderWav.cpp
@@ -59,7 +59,7 @@ bool AudioDecoderWav::open(const char *path) {
}
CC_LOG_DEBUG("wav info: frames: %d, samplerate: %d, channels: %d, format: %d", info.frames, info.samplerate, info.channels, info.format);
_pcmHeader.channelCount = info.channels;
- _pcmHeader.bytesPerFrame = 2 * info.channels; // FIXED_16
+ _pcmHeader.bytesPerFrame = 2 * info.channels; // FIXED_16
_pcmHeader.dataFormat = AudioDataFormat::SIGNED_16; //FIXED,
_pcmHeader.sampleRate = info.samplerate;
_pcmHeader.totalFrames = info.frames;
diff --git a/native/cocos/audio/oalsoft/AudioCache.cpp b/native/cocos/audio/oalsoft/AudioCache.cpp
index af27149565..0b80043aa0 100644
--- a/native/cocos/audio/oalsoft/AudioCache.cpp
+++ b/native/cocos/audio/oalsoft/AudioCache.cpp
@@ -111,7 +111,7 @@ void AudioCache::readDataTask(unsigned int selfId) {
}
const uint32_t originalTotalFrames = decoder->getTotalFrames();
- _bytesPerFrame = decoder->getBytesPerFrame();
+ _bytesPerFrame = decoder->getBytesPerFrame();
const uint32_t sampleRate = decoder->getSampleRate();
_channelCount = decoder->getChannelCount();
diff --git a/native/cocos/base/Assertf.h b/native/cocos/base/Assertf.h
index 385549a1a0..cea0270a8c 100644
--- a/native/cocos/base/Assertf.h
+++ b/native/cocos/base/Assertf.h
@@ -31,15 +31,15 @@
#if CC_DEBUG && !NDEBUG
#if (CC_PLATFORM == CC_PLATFORM_WINDOWS)
- #define CC_ASSERT_FORMAT(cond, fmt, ...) \
- do { \
- if (!(cond)) { \
- char message[256] = {0}; \
- wchar_t messageTmp[256] = {0}; \
+ #define CC_ASSERT_FORMAT(cond, fmt, ...) \
+ do { \
+ if (!(cond)) { \
+ char message[256] = {0}; \
+ wchar_t messageTmp[256] = {0}; \
snprintf(message, sizeof(message), "CC_ASSERT(%s) failed. " fmt "\n%s", #cond, ##__VA_ARGS__, __FUNCTION__); \
- std::copy(message, message + strlen(message), messageTmp); \
- _wassert(messageTmp, _CRT_WIDE(__FILE__), (unsigned)__LINE__); \
- } \
+ std::copy(message, message + strlen(message), messageTmp); \
+ _wassert(messageTmp, _CRT_WIDE(__FILE__), (unsigned)__LINE__); \
+ } \
} while (false)
#define CC_ABORTF(fmt, ...) \
@@ -52,13 +52,13 @@
} while (false)
#elif (CC_PLATFORM == CC_PLATFORM_ANDROID)
- #define CC_ASSERT_FORMAT(cond, fmt, ...) \
- do { \
- if (__builtin_expect(!(cond), 0)) { \
- char message[256] = {0}; \
+ #define CC_ASSERT_FORMAT(cond, fmt, ...) \
+ do { \
+ if (__builtin_expect(!(cond), 0)) { \
+ char message[256] = {0}; \
snprintf(message, sizeof(message), "CC_ASSERT(%s) failed. " fmt, #cond, ##__VA_ARGS__); \
- __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, message); \
- } \
+ __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, message); \
+ } \
} while (false)
#define CC_ABORTF(fmt, ...) \
do { \
@@ -67,19 +67,19 @@
__assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, message); \
} while (false)
#elif CC_PLATFORM == CC_PLATFORM_IOS || CC_PLATFORM == CC_PLATFORM_MACOS
- #define CC_ASSERT_FORMAT(cond, fmt, ...) \
- do { \
- if (__builtin_expect(!(cond), 0)) { \
- char message[256] = {0}; \
+ #define CC_ASSERT_FORMAT(cond, fmt, ...) \
+ do { \
+ if (__builtin_expect(!(cond), 0)) { \
+ char message[256] = {0}; \
snprintf(message, sizeof(message), "CC_ASSERT(%s) failed. " fmt, #cond, ##__VA_ARGS__); \
- __assert(message, __FILE__, __LINE__); \
- } \
+ __assert(message, __FILE__, __LINE__); \
+ } \
} while (false)
- #define CC_ABORTF(fmt, ...) \
- do { \
- char message[256] = {0}; \
+ #define CC_ABORTF(fmt, ...) \
+ do { \
+ char message[256] = {0}; \
snprintf(message, sizeof(message), fmt, ##__VA_ARGS__); \
- __assert(message, __FILE__, __LINE__); \
+ __assert(message, __FILE__, __LINE__); \
} while (false)
#else
#define CC_ASSERT_FORMAT(cond, ...) assert(cond)
@@ -146,8 +146,8 @@
* CC_ABORTF("Invalidate state code %d", statusCode);
* CC_ABORTF("Should crash in debug mode")
*/
- #define CC_ABORT() abort()
- #define CC_ASSERT(cond) _CC_ASSERT_(cond)
+ #define CC_ABORT() abort()
+ #define CC_ASSERT(cond) _CC_ASSERT_(cond)
#else
#define CC_ASSERTF(...) ((void)0)
diff --git a/native/cocos/base/Compressed.cpp b/native/cocos/base/Compressed.cpp
index 4ae15e382c..4f738ec378 100644
--- a/native/cocos/base/Compressed.cpp
+++ b/native/cocos/base/Compressed.cpp
@@ -24,8 +24,8 @@
#include
-#include "base/Utils.h"
#include "base/Compressed.h"
+#include "base/Utils.h"
// compressed file header
static const uint32_t COMPRESSED_HEADER_LENGTH = 4;
@@ -58,7 +58,7 @@ uint32_t getChunkSizes(const unsigned char* pFile, uint32_t level) {
}
unsigned char* getChunk(const unsigned char* pFile, uint32_t level) {
- unsigned char *dstData = nullptr;
+ unsigned char* dstData = nullptr;
const auto chunkCount = getChunkNumbers(pFile);
const auto compressedFileHeaderLength = COMPRESSED_HEADER_LENGTH + COMPRESSED_MIPMAP_LEVEL_COUNT_LENGTH + COMPRESSED_MIPMAP_DATA_SIZE_LENGTH * chunkCount;
diff --git a/native/cocos/base/LogRemote.cpp b/native/cocos/base/LogRemote.cpp
index f2c2043322..b082050a01 100644
--- a/native/cocos/base/LogRemote.cpp
+++ b/native/cocos/base/LogRemote.cpp
@@ -51,7 +51,7 @@
namespace {
// #define AUTO_TEST_CONFIG_FILE "auto-test-config.json" // v1
- #define AUTO_TEST_CONFIG_FILE "testConfig.json" // v2
+ #define AUTO_TEST_CONFIG_FILE "testConfig.json" // v2
#define OLD_ATC_KEY_CONFIG "ServerConfig"
#define OLD_ATC_KEY_IP "IP"
diff --git a/native/cocos/base/TemplateUtils.h b/native/cocos/base/TemplateUtils.h
index 06b16032cd..58815625b7 100644
--- a/native/cocos/base/TemplateUtils.h
+++ b/native/cocos/base/TemplateUtils.h
@@ -36,10 +36,12 @@ namespace cc {
}, value);
*/
-
+
// https://stackoverflow.com/questions/69915380/what-does-templateclass-ts-struct-overloaded-ts-using-tsoperator
// https://en.cppreference.com/w/cpp/language/class_template_argument_deduction
-template struct overloaded : Ts... { using Ts::operator()...; };
-template overloaded(Ts...) -> overloaded;
+template
+struct overloaded : Ts... { using Ts::operator()...; };
+template
+overloaded(Ts...) -> overloaded;
-}
+} // namespace cc
diff --git a/native/cocos/base/memory/MemoryHook.cpp b/native/cocos/base/memory/MemoryHook.cpp
index 60aa80f9e0..9aabe3794a 100644
--- a/native/cocos/base/memory/MemoryHook.cpp
+++ b/native/cocos/base/memory/MemoryHook.cpp
@@ -30,8 +30,8 @@
#if CC_PLATFORM == CC_PLATFORM_ANDROID
#define __GNU_SOURCE
+ #include
#include
- #include
static NewHookType g_new_hooker = nullptr;
static DeleteHookType g_delete_hooker = nullptr;
diff --git a/native/cocos/base/std/container/unordered_map.h b/native/cocos/base/std/container/unordered_map.h
index 164a813570..5927c9f464 100644
--- a/native/cocos/base/std/container/unordered_map.h
+++ b/native/cocos/base/std/container/unordered_map.h
@@ -46,6 +46,6 @@ template <
class T,
class Hash = ccstd::hash,
class Pred = std::equal_to>
-using unordered_multimap =std::unordered_multimap>>;
-}
+using unordered_multimap = std::unordered_multimap>>;
+} // namespace pmr
} // namespace ccstd
diff --git a/native/cocos/bindings/jswrapper/Define.h b/native/cocos/bindings/jswrapper/Define.h
index 1d8a52a192..98222de8d9 100644
--- a/native/cocos/bindings/jswrapper/Define.h
+++ b/native/cocos/bindings/jswrapper/Define.h
@@ -33,15 +33,15 @@ namespace se {
* @note Use the same value as which defined in v8, we convert it to v8::PropertyAttribute directly, so don't change the enum value.
*/
enum class PropertyAttribute : uint8_t {
- /** NONE. **/
- NONE = 0,
- /** READ_ONLY, i.e., not writable. **/
- READ_ONLY = 1 << 0,
- /** DONT_ENUM, i.e., not enumerable. **/
- DONT_ENUM = 1 << 1,
- /** DONT_DELETE, i.e., not configurable. **/
- DONT_DELETE = 1 << 2
+ /** NONE. **/
+ NONE = 0,
+ /** READ_ONLY, i.e., not writable. **/
+ READ_ONLY = 1 << 0,
+ /** DONT_ENUM, i.e., not enumerable. **/
+ DONT_ENUM = 1 << 1,
+ /** DONT_DELETE, i.e., not configurable. **/
+ DONT_DELETE = 1 << 2
};
CC_ENUM_BITWISE_OPERATORS(PropertyAttribute);
-}
+} // namespace se
diff --git a/native/cocos/bindings/jswrapper/MappingUtils.cpp b/native/cocos/bindings/jswrapper/MappingUtils.cpp
index 2d3bb803dc..d871bd05bc 100644
--- a/native/cocos/bindings/jswrapper/MappingUtils.cpp
+++ b/native/cocos/bindings/jswrapper/MappingUtils.cpp
@@ -52,15 +52,18 @@ bool NativePtrToObjectMap::isValid() {
return __isValid;
}
-CC_DEPRECATED(3.7) NativePtrToObjectMap::Map::iterator NativePtrToObjectMap::find(void *v) {
+CC_DEPRECATED(3.7)
+NativePtrToObjectMap::Map::iterator NativePtrToObjectMap::find(void *v) {
return __nativePtrToObjectMap->find(v);
}
-CC_DEPRECATED(3.7) NativePtrToObjectMap::Map::iterator NativePtrToObjectMap::begin() {
+CC_DEPRECATED(3.7)
+NativePtrToObjectMap::Map::iterator NativePtrToObjectMap::begin() {
return __nativePtrToObjectMap->begin();
}
-CC_DEPRECATED(3.7) NativePtrToObjectMap::Map::iterator NativePtrToObjectMap::end() {
+CC_DEPRECATED(3.7)
+NativePtrToObjectMap::Map::iterator NativePtrToObjectMap::end() {
return __nativePtrToObjectMap->end();
}
diff --git a/native/cocos/bindings/jswrapper/State.h b/native/cocos/bindings/jswrapper/State.h
index c9b6c936aa..258042818a 100644
--- a/native/cocos/bindings/jswrapper/State.h
+++ b/native/cocos/bindings/jswrapper/State.h
@@ -29,7 +29,6 @@
#include "PrivateObject.h"
#include "Value.h"
-
namespace se {
class Object;
diff --git a/native/cocos/bindings/jswrapper/v8/Class.cpp b/native/cocos/bindings/jswrapper/v8/Class.cpp
index d1dcd53ff9..ff2432e8d9 100644
--- a/native/cocos/bindings/jswrapper/v8/Class.cpp
+++ b/native/cocos/bindings/jswrapper/v8/Class.cpp
@@ -240,7 +240,7 @@ bool Class::defineStaticProperty(const char *name, v8::FunctionCallback getter,
return true;
}
-bool Class::defineStaticProperty(const char *name, const Value &value, PropertyAttribute attribute/* = PropertyAttribute::NONE */) {
+bool Class::defineStaticProperty(const char *name, const Value &value, PropertyAttribute attribute /* = PropertyAttribute::NONE */) {
v8::MaybeLocal jsName = v8::String::NewFromUtf8(__isolate, name, v8::NewStringType::kNormal);
if (jsName.IsEmpty()) {
return false;
diff --git a/native/cocos/bindings/jswrapper/v8/Class.h b/native/cocos/bindings/jswrapper/v8/Class.h
index 0d5c88ddb5..988487c011 100644
--- a/native/cocos/bindings/jswrapper/v8/Class.h
+++ b/native/cocos/bindings/jswrapper/v8/Class.h
@@ -29,9 +29,9 @@
#if SCRIPT_ENGINE_TYPE == SCRIPT_ENGINE_V8
- #include "Base.h"
- #include "../Value.h"
#include "../Define.h"
+ #include "../Value.h"
+ #include "Base.h"
namespace se {
@@ -105,7 +105,6 @@ public:
*/
bool defineStaticProperty(const char *name, const Value &value, PropertyAttribute attribute = PropertyAttribute::NONE);
-
/**
* @brief Defines the finalize function with a callback.
* @param[in] func The callback to invoke when a JavaScript object is garbage collected.
diff --git a/native/cocos/bindings/jswrapper/v8/HelperMacros.cpp b/native/cocos/bindings/jswrapper/v8/HelperMacros.cpp
index 55403c8afe..03e7abbeac 100644
--- a/native/cocos/bindings/jswrapper/v8/HelperMacros.cpp
+++ b/native/cocos/bindings/jswrapper/v8/HelperMacros.cpp
@@ -24,10 +24,10 @@
#include "HelperMacros.h"
#include "../State.h"
+#include "../ValueArrayPool.h"
+#include "Object.h"
#include "ScriptEngine.h"
#include "Utils.h"
-#include "Object.h"
-#include "../ValueArrayPool.h"
#if defined(RECORD_JSB_INVOKING)
diff --git a/native/cocos/bindings/jswrapper/v8/HelperMacros.h b/native/cocos/bindings/jswrapper/v8/HelperMacros.h
index 7c4bd33264..213855e6d2 100644
--- a/native/cocos/bindings/jswrapper/v8/HelperMacros.h
+++ b/native/cocos/bindings/jswrapper/v8/HelperMacros.h
@@ -105,19 +105,19 @@ void jsbConstructorWrapper(const v8::FunctionCallbackInfo &,
se_finalize_ptr finalizeCb,
se::Class *,
const char *);
-void jsbGetterWrapper(const v8::FunctionCallbackInfo&,
+void jsbGetterWrapper(const v8::FunctionCallbackInfo &,
se_function_ptr,
const char *);
-void jsbSetterWrapper(const v8::FunctionCallbackInfo&,
+void jsbSetterWrapper(const v8::FunctionCallbackInfo &,
se_function_ptr,
const char *);
#ifdef __GNUC__
#define SE_UNUSED __attribute__((unused))
- #define SE_HOT __attribute__((hot))
+ #define SE_HOT __attribute__((hot))
#else
#define SE_UNUSED
- #define SE_HOT
+ #define SE_HOT
#endif
#define SAFE_INC_REF(obj) \
@@ -158,25 +158,25 @@ void jsbSetterWrapper(const v8::FunctionCallbackInfo&,
void funcName##Registry(se::Object *thisObject);
// v8 doesn't need to create a new JSObject in SE_BIND_CTOR while SpiderMonkey needs.
- #define SE_BIND_CTOR(funcName, cls, finalizeCb) \
- void funcName##Registry(const v8::FunctionCallbackInfo &_v8args) { \
- JsbInvokeScope(#funcName); \
+ #define SE_BIND_CTOR(funcName, cls, finalizeCb) \
+ void funcName##Registry(const v8::FunctionCallbackInfo &_v8args) { \
+ JsbInvokeScope(#funcName); \
jsbConstructorWrapper(_v8args, funcName, _SE(finalizeCb), cls, #funcName); \
}
- #define SE_BIND_PROP_GET_IMPL(funcName, postFix) \
- void funcName##postFix##Registry(const v8::FunctionCallbackInfo& _v8args) { \
- JsbInvokeScope(#funcName); \
- jsbGetterWrapper(_v8args, funcName, #funcName); \
+ #define SE_BIND_PROP_GET_IMPL(funcName, postFix) \
+ void funcName##postFix##Registry(const v8::FunctionCallbackInfo &_v8args) { \
+ JsbInvokeScope(#funcName); \
+ jsbGetterWrapper(_v8args, funcName, #funcName); \
}
#define SE_BIND_PROP_GET(funcName) SE_BIND_PROP_GET_IMPL(funcName, )
#define SE_BIND_FUNC_AS_PROP_GET(funcName) SE_BIND_PROP_GET_IMPL(funcName, _asGetter)
- #define SE_BIND_PROP_SET_IMPL(funcName, postFix) \
- void funcName##postFix##Registry(const v8::FunctionCallbackInfo& _v8args) { \
- JsbInvokeScope(#funcName); \
- jsbSetterWrapper(_v8args, funcName, #funcName); \
+ #define SE_BIND_PROP_SET_IMPL(funcName, postFix) \
+ void funcName##postFix##Registry(const v8::FunctionCallbackInfo &_v8args) { \
+ JsbInvokeScope(#funcName); \
+ jsbSetterWrapper(_v8args, funcName, #funcName); \
}
#define SE_BIND_PROP_SET(funcName) SE_BIND_PROP_SET_IMPL(funcName, )
@@ -197,7 +197,7 @@ void jsbSetterWrapper(const v8::FunctionCallbackInfo&,
do { \
if (!(cond)) { \
selogMessage(cc::LogLevel::ERR, "[SE_ASSERT]", (" (%s, %d): " fmt), __FILE__, __LINE__, ##__VA_ARGS__); \
- CC_ABORT(); \
+ CC_ABORT(); \
} \
} while (false)
diff --git a/native/cocos/bindings/jswrapper/v8/Object.cpp b/native/cocos/bindings/jswrapper/v8/Object.cpp
index cba8d05aa4..7cc1bbbd57 100644
--- a/native/cocos/bindings/jswrapper/v8/Object.cpp
+++ b/native/cocos/bindings/jswrapper/v8/Object.cpp
@@ -243,9 +243,9 @@ Object *Object::createExternalArrayBufferObject(void *contents, size_t byteLengt
Object *obj = nullptr;
#if CC_EDITOR && CC_PLATFORM == CC_PLATFORM_WINDOWS
auto nodeBuffer = node::Buffer::New(
- __isolate, (char *)contents, byteLength, [](char *data, void *hint) {}, nullptr)
- .ToLocalChecked()
- .As();
+ __isolate, (char *)contents, byteLength, [](char *data, void *hint) {}, nullptr)
+ .ToLocalChecked()
+ .As();
v8::Local jsobj = nodeBuffer.As()->Buffer();
#else
std::shared_ptr backingStore = v8::ArrayBuffer::NewBackingStore(contents, byteLength, freeFunc, freeUserData);
diff --git a/native/cocos/bindings/jswrapper/v8/Object.h b/native/cocos/bindings/jswrapper/v8/Object.h
index 5ee6593eb7..0ec3119a40 100644
--- a/native/cocos/bindings/jswrapper/v8/Object.h
+++ b/native/cocos/bindings/jswrapper/v8/Object.h
@@ -184,7 +184,8 @@ public:
* @note The return value (non-null) has to be released manually.
* @deprecated Use NativePtrToObjectMap to query the native object.
*/
- CC_DEPRECATED(3.7) static Object *getObjectWithPtr(void *ptr);
+ CC_DEPRECATED(3.7)
+ static Object *getObjectWithPtr(void *ptr);
/**
* @brief Gets a property from an object.
diff --git a/native/cocos/bindings/jswrapper/v8/ScriptEngine.cpp b/native/cocos/bindings/jswrapper/v8/ScriptEngine.cpp
index 87537d3bcb..be97dbeb06 100644
--- a/native/cocos/bindings/jswrapper/v8/ScriptEngine.cpp
+++ b/native/cocos/bindings/jswrapper/v8/ScriptEngine.cpp
@@ -575,7 +575,6 @@ bool ScriptEngine::postInit() {
_isValid = true;
-
// @deprecated since 3.7.0
cc::plugin::send(cc::plugin::BusType::SCRIPT_ENGINE, cc::plugin::ScriptEngineEvent::POST_INIT);
diff --git a/native/cocos/bindings/manual/jsb_ar_manual.cpp b/native/cocos/bindings/manual/jsb_ar_manual.cpp
index 85b521b56c..6f3d336b29 100644
--- a/native/cocos/bindings/manual/jsb_ar_manual.cpp
+++ b/native/cocos/bindings/manual/jsb_ar_manual.cpp
@@ -24,11 +24,10 @@
#include "jsb_ar_manual.h"
-#include "bindings/manual/jsb_global.h"
#include "bindings/auto/jsb_ar_auto.h"
+#include "bindings/manual/jsb_global.h"
-static bool js_ar_ARModule_getAddedPlanesInfo(se::State& s)
-{
+static bool js_ar_ARModule_getAddedPlanesInfo(se::State& s) {
cc::ar::ARModule* cobj = (cc::ar::ARModule*)s.nativeThisObject();
if (nullptr == cobj) return true;
const auto& args = s.args();
@@ -49,8 +48,7 @@ static bool js_ar_ARModule_getAddedPlanesInfo(se::State& s)
SE_BIND_FUNC(js_ar_ARModule_getAddedPlanesInfo)
-static bool js_ar_ARModule_getUpdatedPlanesInfo(se::State& s)
-{
+static bool js_ar_ARModule_getUpdatedPlanesInfo(se::State& s) {
cc::ar::ARModule* cobj = (cc::ar::ARModule*)s.nativeThisObject();
if (nullptr == cobj) return true;
const auto& args = s.args();
@@ -69,8 +67,7 @@ static bool js_ar_ARModule_getUpdatedPlanesInfo(se::State& s)
}
SE_BIND_FUNC(js_ar_ARModule_getUpdatedPlanesInfo)
-static bool js_ar_ARModule_getRemovedPlanesInfo(se::State& s)
-{
+static bool js_ar_ARModule_getRemovedPlanesInfo(se::State& s) {
auto* cobj = SE_THIS_OBJECT(s);
if (nullptr == cobj) return true;
const auto& args = s.args();
@@ -89,8 +86,7 @@ static bool js_ar_ARModule_getRemovedPlanesInfo(se::State& s)
}
SE_BIND_FUNC(js_ar_ARModule_getRemovedPlanesInfo)
-static bool js_ar_ARModule_getPlanePolygon(se::State& s)
-{
+static bool js_ar_ARModule_getPlanePolygon(se::State& s) {
cc::ar::ARModule* cobj = (cc::ar::ARModule*)s.nativeThisObject();
SE_PRECONDITION2(cobj, false, "js_ar_ARModule_getPlanePolygon : Invalid Native Object");
@@ -114,8 +110,7 @@ static bool js_ar_ARModule_getPlanePolygon(se::State& s)
}
SE_BIND_FUNC(js_ar_ARModule_getPlanePolygon)
-static bool js_ar_ARModule_getAddedSceneMesh(se::State& s)
-{
+static bool js_ar_ARModule_getAddedSceneMesh(se::State& s) {
cc::ar::ARModule* cobj = (cc::ar::ARModule*)s.nativeThisObject();
SE_PRECONDITION2(cobj, false, "js_ar_ARModule_getAddedSceneMesh : Invalid Native Object");
@@ -134,8 +129,7 @@ static bool js_ar_ARModule_getAddedSceneMesh(se::State& s)
}
SE_BIND_FUNC(js_ar_ARModule_getAddedSceneMesh)
-static bool js_ar_ARModule_getUpdatedSceneMesh(se::State& s)
-{
+static bool js_ar_ARModule_getUpdatedSceneMesh(se::State& s) {
cc::ar::ARModule* cobj = (cc::ar::ARModule*)s.nativeThisObject();
SE_PRECONDITION2(cobj, false, "js_ar_ARModule_getUpdatedSceneMesh : Invalid Native Object");
@@ -154,8 +148,7 @@ static bool js_ar_ARModule_getUpdatedSceneMesh(se::State& s)
}
SE_BIND_FUNC(js_ar_ARModule_getUpdatedSceneMesh)
-static bool js_ar_ARModule_getRemovedSceneMesh(se::State& s)
-{
+static bool js_ar_ARModule_getRemovedSceneMesh(se::State& s) {
cc::ar::ARModule* cobj = (cc::ar::ARModule*)s.nativeThisObject();
SE_PRECONDITION2(cobj, false, "js_ar_ARModule_getRemovedSceneMesh : Invalid Native Object");
@@ -174,8 +167,7 @@ static bool js_ar_ARModule_getRemovedSceneMesh(se::State& s)
}
SE_BIND_FUNC(js_ar_ARModule_getRemovedSceneMesh)
-static bool js_ar_ARModule_requireSceneMesh(se::State& s)
-{
+static bool js_ar_ARModule_requireSceneMesh(se::State& s) {
cc::ar::ARModule* cobj = (cc::ar::ARModule*)s.nativeThisObject();
SE_PRECONDITION2(cobj, false, "js_ar_ARModule_requireSceneMesh : Invalid Native Object");
@@ -194,8 +186,7 @@ static bool js_ar_ARModule_requireSceneMesh(se::State& s)
}
SE_BIND_FUNC(js_ar_ARModule_requireSceneMesh)
-static bool js_ar_ARModule_getSceneMeshVertices(se::State& s)
-{
+static bool js_ar_ARModule_getSceneMeshVertices(se::State& s) {
cc::ar::ARModule* cobj = (cc::ar::ARModule*)s.nativeThisObject();
SE_PRECONDITION2(cobj, false, "js_ar_ARModule_getSceneMeshVertices : Invalid Native Object");
@@ -219,8 +210,7 @@ static bool js_ar_ARModule_getSceneMeshVertices(se::State& s)
}
SE_BIND_FUNC(js_ar_ARModule_getSceneMeshVertices)
-static bool js_ar_ARModule_getSceneMeshTriangleIndices(se::State& s)
-{
+static bool js_ar_ARModule_getSceneMeshTriangleIndices(se::State& s) {
cc::ar::ARModule* cobj = (cc::ar::ARModule*)s.nativeThisObject();
SE_PRECONDITION2(cobj, false, "js_ar_ARModule_getSceneMeshTriangleIndices : Invalid Native Object");
@@ -244,8 +234,7 @@ static bool js_ar_ARModule_getSceneMeshTriangleIndices(se::State& s)
}
SE_BIND_FUNC(js_ar_ARModule_getSceneMeshTriangleIndices)
-static bool js_ar_ARModule_getAddedImagesInfo(se::State& s)
-{
+static bool js_ar_ARModule_getAddedImagesInfo(se::State& s) {
cc::ar::ARModule* cobj = (cc::ar::ARModule*)s.nativeThisObject();
SE_PRECONDITION2(cobj, false, "js_ar_ARModule_getAddedImagesInfo : Invalid Native Object");
@@ -264,8 +253,7 @@ static bool js_ar_ARModule_getAddedImagesInfo(se::State& s)
}
SE_BIND_FUNC(js_ar_ARModule_getAddedImagesInfo)
-static bool js_ar_ARModule_getUpdatedImagesInfo(se::State& s)
-{
+static bool js_ar_ARModule_getUpdatedImagesInfo(se::State& s) {
cc::ar::ARModule* cobj = (cc::ar::ARModule*)s.nativeThisObject();
SE_PRECONDITION2(cobj, false, "js_ar_ARModule_getUpdatedImagesInfo : Invalid Native Object");
@@ -284,8 +272,7 @@ static bool js_ar_ARModule_getUpdatedImagesInfo(se::State& s)
}
SE_BIND_FUNC(js_ar_ARModule_getUpdatedImagesInfo)
-static bool js_ar_ARModule_getRemovedImagesInfo(se::State& s)
-{
+static bool js_ar_ARModule_getRemovedImagesInfo(se::State& s) {
cc::ar::ARModule* cobj = (cc::ar::ARModule*)s.nativeThisObject();
SE_PRECONDITION2(cobj, false, "js_ar_ARModule_getRemovedImagesInfo : Invalid Native Object");
@@ -304,8 +291,7 @@ static bool js_ar_ARModule_getRemovedImagesInfo(se::State& s)
}
SE_BIND_FUNC(js_ar_ARModule_getRemovedImagesInfo)
-static bool js_ar_ARModule_getAddedObjectsInfo(se::State& s)
-{
+static bool js_ar_ARModule_getAddedObjectsInfo(se::State& s) {
cc::ar::ARModule* cobj = (cc::ar::ARModule*)s.nativeThisObject();
SE_PRECONDITION2(cobj, false, "js_ar_ARModule_getAddedObjectsInfo : Invalid Native Object");
@@ -324,8 +310,7 @@ static bool js_ar_ARModule_getAddedObjectsInfo(se::State& s)
}
SE_BIND_FUNC(js_ar_ARModule_getAddedObjectsInfo)
-static bool js_ar_ARModule_getUpdatedObjectsInfo(se::State& s)
-{
+static bool js_ar_ARModule_getUpdatedObjectsInfo(se::State& s) {
cc::ar::ARModule* cobj = (cc::ar::ARModule*)s.nativeThisObject();
SE_PRECONDITION2(cobj, false, "js_ar_ARModule_getUpdatedObjectsInfo : Invalid Native Object");
@@ -344,8 +329,7 @@ static bool js_ar_ARModule_getUpdatedObjectsInfo(se::State& s)
}
SE_BIND_FUNC(js_ar_ARModule_getUpdatedObjectsInfo)
-static bool js_ar_ARModule_getRemovedObjectsInfo(se::State& s)
-{
+static bool js_ar_ARModule_getRemovedObjectsInfo(se::State& s) {
cc::ar::ARModule* cobj = (cc::ar::ARModule*)s.nativeThisObject();
SE_PRECONDITION2(cobj, false, "js_ar_ARModule_getRemovedObjectsInfo : Invalid Native Object");
@@ -364,8 +348,7 @@ static bool js_ar_ARModule_getRemovedObjectsInfo(se::State& s)
}
SE_BIND_FUNC(js_ar_ARModule_getRemovedObjectsInfo)
-static bool js_ar_ARModule_getAddedFacesInfo(se::State& s)
-{
+static bool js_ar_ARModule_getAddedFacesInfo(se::State& s) {
auto* cobj = static_cast(s.nativeThisObject());
SE_PRECONDITION2(cobj, false, "js_ar_ARModule_getAddedFacesInfo : Invalid Native Object");
@@ -384,8 +367,7 @@ static bool js_ar_ARModule_getAddedFacesInfo(se::State& s)
}
SE_BIND_FUNC(js_ar_ARModule_getAddedFacesInfo)
-static bool js_ar_ARModule_getUpdatedFacesInfo(se::State& s)
-{
+static bool js_ar_ARModule_getUpdatedFacesInfo(se::State& s) {
cc::ar::ARModule* cobj = (cc::ar::ARModule*)s.nativeThisObject();
SE_PRECONDITION2(cobj, false, "js_ar_ARModule_getUpdatedFacesInfo : Invalid Native Object");
@@ -404,8 +386,7 @@ static bool js_ar_ARModule_getUpdatedFacesInfo(se::State& s)
}
SE_BIND_FUNC(js_ar_ARModule_getUpdatedFacesInfo)
-static bool js_ar_ARModule_getRemovedFacesInfo(se::State& s)
-{
+static bool js_ar_ARModule_getRemovedFacesInfo(se::State& s) {
cc::ar::ARModule* cobj = (cc::ar::ARModule*)s.nativeThisObject();
SE_PRECONDITION2(cobj, false, "js_ar_ARModule_getRemovedFacesInfo : Invalid Native Object");
@@ -424,8 +405,7 @@ static bool js_ar_ARModule_getRemovedFacesInfo(se::State& s)
}
SE_BIND_FUNC(js_ar_ARModule_getRemovedFacesInfo)
-static bool js_ar_ARModule_getFaceBlendShapes(se::State& s)
-{
+static bool js_ar_ARModule_getFaceBlendShapes(se::State& s) {
cc::ar::ARModule* cobj = (cc::ar::ARModule*)s.nativeThisObject();
SE_PRECONDITION2(cobj, false, "js_ar_ARModule_getFaceBlendShapes : Invalid Native Object");
@@ -449,7 +429,7 @@ static bool js_ar_ARModule_getFaceBlendShapes(se::State& s)
}
SE_BIND_FUNC(js_ar_ARModule_getFaceBlendShapes)
-bool register_all_ar_manual(se::Object *obj) {
+bool register_all_ar_manual(se::Object* obj) {
__jsb_cc_ar_ARModule_proto->defineFunction("getAddedPlanesInfo", _SE(js_ar_ARModule_getAddedPlanesInfo));
__jsb_cc_ar_ARModule_proto->defineFunction("getUpdatedPlanesInfo", _SE(js_ar_ARModule_getUpdatedPlanesInfo));
__jsb_cc_ar_ARModule_proto->defineFunction("getRemovedPlanesInfo", _SE(js_ar_ARModule_getRemovedPlanesInfo));
diff --git a/native/cocos/bindings/manual/jsb_assets_manual.cpp b/native/cocos/bindings/manual/jsb_assets_manual.cpp
index 7859403417..41db6397a6 100644
--- a/native/cocos/bindings/manual/jsb_assets_manual.cpp
+++ b/native/cocos/bindings/manual/jsb_assets_manual.cpp
@@ -111,7 +111,7 @@ static bool js_assets_Material_registerPassesUpdatedListener(se::State &s) // NO
auto *cobj = SE_THIS_OBJECT(s);
SE_PRECONDITION2(cobj, false, "Invalid Native Object");
auto *thisObj = s.thisObject();
- cobj->on([thisObj](cc::Material * /*emitter*/ ){
+ cobj->on([thisObj](cc::Material * /*emitter*/) {
se::AutoHandleScope hs;
se::ScriptEngine::getInstance()->callFunction(thisObj, "_onPassesUpdated", 0, nullptr);
});
diff --git a/native/cocos/bindings/manual/jsb_cocos_manual.cpp b/native/cocos/bindings/manual/jsb_cocos_manual.cpp
index b966dcfee3..30ba3d6608 100644
--- a/native/cocos/bindings/manual/jsb_cocos_manual.cpp
+++ b/native/cocos/bindings/manual/jsb_cocos_manual.cpp
@@ -751,7 +751,7 @@ static bool register_platform(se::Object * /*obj*/) { // NOLINT(readability-iden
}
template
-static bool bindAsExternalBuffer(se::State &s) { // NOLINT
+static bool bindAsExternalBuffer(se::State &s) { // NOLINT
auto *self = SE_THIS_OBJECT(s);
if (!self) {
return false;
@@ -792,7 +792,6 @@ static bool js_cc_Quaternion_underlyingData(se::State &s) { // NOLINT
}
SE_BIND_FUNC(js_cc_Quaternion_underlyingData)
-
bool register_all_cocos_manual(se::Object *obj) { // NOLINT(readability-identifier-naming)
__jsb_cc_Vec2_proto->defineFunction("underlyingData", _SE(js_cc_Vec2_underlyingData));
diff --git a/native/cocos/bindings/manual/jsb_conversions_spec.cpp b/native/cocos/bindings/manual/jsb_conversions_spec.cpp
index 1de86166f7..d8b1f78dec 100644
--- a/native/cocos/bindings/manual/jsb_conversions_spec.cpp
+++ b/native/cocos/bindings/manual/jsb_conversions_spec.cpp
@@ -21,9 +21,9 @@
****************************************************************************/
#include
-#include "base/Value.h"
#include "base/DeferredReleasePool.h"
#include "base/TemplateUtils.h"
+#include "base/Value.h"
#include "cocos/base/RefMap.h"
#include "cocos/base/RefVector.h"
#include "cocos/core/TypedArray.h"
@@ -58,7 +58,6 @@
return true; \
}
-
template
typename std::enable_if::value, bool>::type
set_member_field(se::Object *obj, T *to, const ccstd::string &property, F f, se::Value &tmp) { // NOLINT
@@ -912,27 +911,23 @@ bool sevalue_to_native(const se::Value &from, cc::IPropertyEditorValueType *to,
ccstd::string str;
ret = sevalue_to_native(from, &str, ctx);
*to = std::move(str);
- }
- break;
+ } break;
case se::Value::Type::Boolean: {
bool v{false};
ret = sevalue_to_native(from, &v, ctx);
*to = v;
- }
- break;
+ } break;
case se::Value::Type::Number: {
float v{0.F};
ret = sevalue_to_native(from, &v, ctx);
*to = v;
- }
- break;
+ } break;
case se::Value::Type::Object: {
CC_ASSERT_TRUE(from.toObject()->isArray());
ccstd::vector v;
ret = sevalue_to_native(from, &v, ctx);
*to = std::move(v);
- }
- break;
+ } break;
default:
*to = {};
break;
@@ -1097,11 +1092,10 @@ bool sevalue_to_native(const se::Value &from, cc::TypedArray *to, se::Object * /
}
ccstd::visit(cc::overloaded{
- [&](auto &typedArray) {
- typedArray.setJSTypedArray(from.toObject());
- },
- [](ccstd::monostate& /*unused*/) {}
- },
+ [&](auto &typedArray) {
+ typedArray.setJSTypedArray(from.toObject());
+ },
+ [](ccstd::monostate & /*unused*/) {}},
*to);
return true;
}
@@ -1109,11 +1103,10 @@ bool sevalue_to_native(const se::Value &from, cc::TypedArray *to, se::Object * /
// NOLINTNEXTLINE(readability-identifier-naming)
bool sevalue_to_native(const se::Value &from, cc::IBArray *to, se::Object * /*ctx*/) {
ccstd::visit(cc::overloaded{
- [&](auto &typedArray) {
- typedArray.setJSTypedArray(from.toObject());
- },
- [](ccstd::monostate& /*unused*/) {}
- },
+ [&](auto &typedArray) {
+ typedArray.setJSTypedArray(from.toObject());
+ },
+ [](ccstd::monostate & /*unused*/) {}},
*to);
return true;
diff --git a/native/cocos/bindings/manual/jsb_conversions_spec.h b/native/cocos/bindings/manual/jsb_conversions_spec.h
index 3ed0f63f38..f288f86248 100644
--- a/native/cocos/bindings/manual/jsb_conversions_spec.h
+++ b/native/cocos/bindings/manual/jsb_conversions_spec.h
@@ -374,9 +374,9 @@ bool sevalue_to_native(const se::Value &from, cc::ValueMap *to, se::Object * /*c
bool sevalue_to_native(const se::Value &from, ccstd::vector *to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming)
-bool sevalue_to_native(const se::Value &from, ccstd::vector *to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming)
-bool sevalue_to_native(const se::Value &from, cc::IPropertyValue *to, se::Object *ctx); // NOLINT(readability-identifier-naming)
-inline bool sevalue_to_native(const se::Value & /*from*/, ccstd::monostate * /*to*/, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming)
+bool sevalue_to_native(const se::Value &from, ccstd::vector *to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming)
+bool sevalue_to_native(const se::Value &from, cc::IPropertyValue *to, se::Object *ctx); // NOLINT(readability-identifier-naming)
+inline bool sevalue_to_native(const se::Value & /*from*/, ccstd::monostate * /*to*/, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming)
// nothing todo
return false;
}
diff --git a/native/cocos/bindings/manual/jsb_dragonbones_manual.cpp b/native/cocos/bindings/manual/jsb_dragonbones_manual.cpp
index ed3d6ce20a..94da7a7c4c 100644
--- a/native/cocos/bindings/manual/jsb_dragonbones_manual.cpp
+++ b/native/cocos/bindings/manual/jsb_dragonbones_manual.cpp
@@ -433,7 +433,7 @@ bool register_all_dragonbones_manual(se::Object *obj) {
if (!se::NativePtrToObjectMap::isValid()) {
return;
}
- se::NativePtrToObjectMap::forEach(obj, [](se::Object *seObj){
+ se::NativePtrToObjectMap::forEach(obj, [](se::Object *seObj) {
seObj->setClearMappingInFinalizer(false);
// Unmap native and js object since native object was destroyed.
// Otherwise, it may trigger 'assertion' in se::Object::setPrivateData later
diff --git a/native/cocos/bindings/manual/jsb_global.cpp b/native/cocos/bindings/manual/jsb_global.cpp
index 854410608c..e92d0b4f08 100644
--- a/native/cocos/bindings/manual/jsb_global.cpp
+++ b/native/cocos/bindings/manual/jsb_global.cpp
@@ -599,7 +599,7 @@ bool jsb_global_load_image(const ccstd::string &path, const se::Value &callbackV
retObj->setProperty("data", se::Value(obj));
retObj->setProperty("width", se::Value(imgInfo->width));
retObj->setProperty("height", se::Value(imgInfo->height));
-
+
se::Value mipmapLevelDataSizeArr;
nativevalue_to_se(imgInfo->mipmapLevelDataSize, mipmapLevelDataSizeArr, nullptr);
retObj->setProperty("mipmapLevelDataSize", mipmapLevelDataSizeArr);
diff --git a/native/cocos/bindings/manual/jsb_module_register.cpp b/native/cocos/bindings/manual/jsb_module_register.cpp
index 82e55da16e..4d5fcb5512 100644
--- a/native/cocos/bindings/manual/jsb_module_register.cpp
+++ b/native/cocos/bindings/manual/jsb_module_register.cpp
@@ -39,8 +39,8 @@
#include "cocos/bindings/jswrapper/SeApi.h"
#include "cocos/bindings/manual/jsb_assets_manual.h"
#include "cocos/bindings/manual/jsb_cocos_manual.h"
-#include "cocos/bindings/manual/jsb_geometry_manual.h"
#include "cocos/bindings/manual/jsb_conversions.h"
+#include "cocos/bindings/manual/jsb_geometry_manual.h"
#include "cocos/bindings/manual/jsb_gfx_manual.h"
#include "cocos/bindings/manual/jsb_global.h"
#include "cocos/bindings/manual/jsb_network_manual.h"
diff --git a/native/cocos/bindings/manual/jsb_scene_manual.cpp b/native/cocos/bindings/manual/jsb_scene_manual.cpp
index e332ceebcd..d01f04d57a 100644
--- a/native/cocos/bindings/manual/jsb_scene_manual.cpp
+++ b/native/cocos/bindings/manual/jsb_scene_manual.cpp
@@ -23,8 +23,8 @@
****************************************************************************/
#include "jsb_scene_manual.h"
-#include "bindings/auto/jsb_scene_auto.h"
#include "bindings/auto/jsb_gfx_auto.h"
+#include "bindings/auto/jsb_scene_auto.h"
#include "core/Root.h"
#include "core/scene-graph/Node.h"
#include "scene/Model.h"
@@ -683,7 +683,7 @@ static bool js_Model_setInstancedAttribute(se::State &s) // NOLINT(readability-i
default:
// FIXME:
- CC_ABORT();
+ CC_ABORT();
break;
}
return true;
@@ -728,7 +728,7 @@ static bool js_Model_registerListeners(se::State &s) // NOLINT(readability-ident
se::ScriptEngine::getInstance()->callFunction(thiz, "_updateLocalDescriptors", static_cast(args.size()), args.data());
});
- cobj->on([=](cc::scene::Model * /*emitter*/,index_t subModelIndex, cc::gfx::DescriptorSet *descriptorSet) {
+ cobj->on([=](cc::scene::Model * /*emitter*/, index_t subModelIndex, cc::gfx::DescriptorSet *descriptorSet) {
cobj->setCalledFromJS(true);
se::AutoHandleScope hs;
@@ -738,7 +738,7 @@ static bool js_Model_registerListeners(se::State &s) // NOLINT(readability-ident
se::ScriptEngine::getInstance()->callFunction(thiz, "_updateLocalSHDescriptors", static_cast(args.size()), args.data());
});
- cobj->on([=](cc::scene::Model * /*emitter*/,index_t subModelIndex, cc::gfx::DescriptorSet *descriptorSet) {
+ cobj->on([=](cc::scene::Model * /*emitter*/, index_t subModelIndex, cc::gfx::DescriptorSet *descriptorSet) {
cobj->setCalledFromJS(true);
se::AutoHandleScope hs;
@@ -748,7 +748,7 @@ static bool js_Model_registerListeners(se::State &s) // NOLINT(readability-ident
se::ScriptEngine::getInstance()->callFunction(thiz, "_updateWorldBoundDescriptors", static_cast(args.size()), args.data());
});
- cobj->on([=](cc::scene::Model * /*emitter*/,const ccstd::vector &attributes, cc::scene::SubModel *subModel) {
+ cobj->on([=](cc::scene::Model * /*emitter*/, const ccstd::vector &attributes, cc::scene::SubModel *subModel) {
cobj->setCalledFromJS(true);
se::AutoHandleScope hs;
diff --git a/native/cocos/bindings/manual/jsb_spine_manual.cpp b/native/cocos/bindings/manual/jsb_spine_manual.cpp
index 51870360e5..5eef226692 100644
--- a/native/cocos/bindings/manual/jsb_spine_manual.cpp
+++ b/native/cocos/bindings/manual/jsb_spine_manual.cpp
@@ -233,7 +233,7 @@ bool register_all_spine_manual(se::Object *obj) {
return;
}
// Support Native Spine fo Creator V3.0
- se::NativePtrToObjectMap::forEach(spineObj, [](se::Object *seObj){
+ se::NativePtrToObjectMap::forEach(spineObj, [](se::Object *seObj) {
// Unmap native and js object since native object was destroyed.
// Otherwise, it may trigger 'assertion' in se::Object::setPrivateData later
// since native obj is already released and the new native object may be assigned with
diff --git a/native/cocos/bindings/manual/jsb_websocket.cpp b/native/cocos/bindings/manual/jsb_websocket.cpp
index d1158a0845..b20a0c0eaf 100644
--- a/native/cocos/bindings/manual/jsb_websocket.cpp
+++ b/native/cocos/bindings/manual/jsb_websocket.cpp
@@ -512,13 +512,12 @@ WEBSOCKET_DEFINE_READONLY_INT_FIELD(Websocket_CLOSED, static_cast(cc::netwo
bool register_all_websocket(se::Object *global) { // NOLINT (readability-identifier-naming)
se::Value nsVal;
- if (!global->getProperty("jsb", &nsVal, true))
- {
+ if (!global->getProperty("jsb", &nsVal, true)) {
se::HandleObject jsobj(se::Object::createPlainObject());
nsVal.setObject(jsobj);
global->setProperty("jsb", nsVal);
}
- se::Object* ns = nsVal.toObject();
+ se::Object *ns = nsVal.toObject();
se::Class *cls = se::Class::create("WebSocket", ns, nullptr, _SE(webSocketConstructor));
cls->defineFinalizeFunction(_SE(webSocketFinalize));
diff --git a/native/cocos/bindings/manual/jsb_xmlhttprequest.cpp b/native/cocos/bindings/manual/jsb_xmlhttprequest.cpp
index f81348eb0d..dd37ca74f4 100644
--- a/native/cocos/bindings/manual/jsb_xmlhttprequest.cpp
+++ b/native/cocos/bindings/manual/jsb_xmlhttprequest.cpp
@@ -959,13 +959,12 @@ SE_BIND_PROP_GET(XMLHttpRequest_getWithCredentials)
bool register_all_xmlhttprequest(se::Object *global) { //NOLINT(readability-identifier-naming)
se::Value nsVal;
- if (!global->getProperty("jsb", &nsVal, true))
- {
+ if (!global->getProperty("jsb", &nsVal, true)) {
se::HandleObject jsobj(se::Object::createPlainObject());
nsVal.setObject(jsobj);
global->setProperty("jsb", nsVal);
}
- se::Object* ns = nsVal.toObject();
+ se::Object *ns = nsVal.toObject();
se::Class *cls = se::Class::create("XMLHttpRequest", ns, nullptr, _SE(XMLHttpRequest_constructor));
cls->defineFinalizeFunction(_SE(XMLHttpRequest_finalize));
diff --git a/native/cocos/cocos-version.h b/native/cocos/cocos-version.h
index 56ff295308..2e6616c0f4 100644
--- a/native/cocos/cocos-version.h
+++ b/native/cocos/cocos-version.h
@@ -23,11 +23,11 @@
****************************************************************************/
#pragma once
-#define COCOS_MAJOR_VERSION 3
-#define COCOS_MINJOR_VERSION 7
-#define COCOS_PATCH_VERSION 0
-#define COCOS_VERSION_STRING "3.7.0"
-#define COCOS_VERSION_DEFINED 1
-#define COCOS_VERSION 30700
+#define COCOS_MAJOR_VERSION 3
+#define COCOS_MINJOR_VERSION 7
+#define COCOS_PATCH_VERSION 0
+#define COCOS_VERSION_STRING "3.7.0"
+#define COCOS_VERSION_DEFINED 1
+#define COCOS_VERSION 30700
// #define COCOS_PRE_RELEASE "release"
diff --git a/native/cocos/cocos.h b/native/cocos/cocos.h
index 383579e035..395f990120 100644
--- a/native/cocos/cocos.h
+++ b/native/cocos/cocos.h
@@ -26,7 +26,6 @@
// public headers for user application
-#include "cocos-version.h"
#include "application/ApplicationManager.h"
#include "application/BaseGame.h"
#include "bindings/event/EventDispatcher.h"
@@ -34,4 +33,5 @@
#include "bindings/manual/jsb_classtype.h"
#include "bindings/manual/jsb_global.h"
#include "bindings/manual/jsb_module_register.h"
+#include "cocos-version.h"
#include "core/event/Event.h"
\ No newline at end of file
diff --git a/native/cocos/core/DataView.cpp b/native/cocos/core/DataView.cpp
index b91d430be1..6a6057f5c8 100644
--- a/native/cocos/core/DataView.cpp
+++ b/native/cocos/core/DataView.cpp
@@ -50,11 +50,10 @@ ccstd::unordered_map DataView::intWritterMa
int32_t DataView::readInt(ReaderVariant &readerVariant, uint32_t offset) {
return ccstd::visit(overloaded{
- [offset, this](auto &reader) {
- return static_cast((this->*reader)(offset));
- },
- [](ccstd::monostate& /*unused*/){ return 0; }
- },
+ [offset, this](auto &reader) {
+ return static_cast((this->*reader)(offset));
+ },
+ [](ccstd::monostate & /*unused*/) { return 0; }},
readerVariant);
}
diff --git a/native/cocos/core/Root.cpp b/native/cocos/core/Root.cpp
index d91f32a7b9..9edc74cb48 100644
--- a/native/cocos/core/Root.cpp
+++ b/native/cocos/core/Root.cpp
@@ -48,7 +48,6 @@
#include "scene/DirectionalLight.h"
#include "scene/SpotLight.h"
-
namespace cc {
namespace {
@@ -111,7 +110,7 @@ scene::RenderWindow *Root::createRenderWindowFromSystemWindow(ISystemWindow *win
gfx::SwapchainInfo info;
info.width = static_cast(size.width);
info.height = static_cast(size.height);
- info.windowHandle = reinterpret_cast(handle); // NOLINT
+ info.windowHandle = reinterpret_cast(handle); // NOLINT
info.windowId = window->getWindowId();
gfx::Swapchain *swapchain = gfx::Device::getInstance()->createSwapchain(info);
diff --git a/native/cocos/core/assets/EffectAsset.h b/native/cocos/core/assets/EffectAsset.h
index 731a7fad7d..cb535a94f2 100644
--- a/native/cocos/core/assets/EffectAsset.h
+++ b/native/cocos/core/assets/EffectAsset.h
@@ -37,7 +37,6 @@
#include "renderer/gfx-base/GFXDef.h"
#include "renderer/pipeline/Define.h"
-
namespace cc {
using IPropertyHandleInfo = std::tuple;
@@ -53,7 +52,7 @@ struct IPropertyInfo {
ccstd::optional samplerHash; // auto-generated from 'sampler'
ccstd::optional value; // default value
ccstd::optional linear; // whether to convert the input to linear space first before applying
- IPropertyEditorInfo editor; // NOTE: used only by editor.
+ IPropertyEditorInfo editor; // NOTE: used only by editor.
};
struct IPassInfoFull;
@@ -479,7 +478,7 @@ struct IDefineInfo {
ccstd::optional> range; // cjh number is float? ?: number[];
ccstd::optional> options;
ccstd::optional defaultVal;
- ccstd::optional> defines; // NOTE: it's only used in Editor
+ ccstd::optional> defines; // NOTE: it's only used in Editor
ccstd::optional> editor; // NOTE: it's only used in Editor
};
diff --git a/native/cocos/core/assets/ImageAsset.h b/native/cocos/core/assets/ImageAsset.h
index 4a49ec78bd..7026dac26b 100644
--- a/native/cocos/core/assets/ImageAsset.h
+++ b/native/cocos/core/assets/ImageAsset.h
@@ -120,7 +120,7 @@ private:
uint32_t _width{0};
uint32_t _height{0};
- bool _needFreeData{false}; // Should free data if the data is assigned in C++.
+ bool _needFreeData{false}; // Should free data if the data is assigned in C++.
ArrayBuffer::Ptr _arrayBuffer; //minggo: hold the data from ImageSource.
diff --git a/native/cocos/core/assets/SceneAsset.cpp b/native/cocos/core/assets/SceneAsset.cpp
index 711d6c851d..dd3e54ebc1 100644
--- a/native/cocos/core/assets/SceneAsset.cpp
+++ b/native/cocos/core/assets/SceneAsset.cpp
@@ -23,8 +23,8 @@
****************************************************************************/
#include "core/assets/SceneAsset.h"
-#include "core/scene-graph/Scene.h"
#include "base/memory/Memory.h"
+#include "core/scene-graph/Scene.h"
namespace cc {
diff --git a/native/cocos/core/assets/Texture2D.cpp b/native/cocos/core/assets/Texture2D.cpp
index 79da6be5e4..28b7c24d85 100644
--- a/native/cocos/core/assets/Texture2D.cpp
+++ b/native/cocos/core/assets/Texture2D.cpp
@@ -66,7 +66,7 @@ void Texture2D::setMipmaps(const ccstd::vector> &value)
}
}
-void Texture2D::setMipmapParams(const ccstd::vector>& value) {
+void Texture2D::setMipmapParams(const ccstd::vector> &value) {
_mipmaps = value;
setMipmapLevel(static_cast(_mipmaps.size()));
if (!_mipmaps.empty()) {
diff --git a/native/cocos/core/event/EventBus.h b/native/cocos/core/event/EventBus.h
index d44e0fc7bb..359bac28f9 100644
--- a/native/cocos/core/event/EventBus.h
+++ b/native/cocos/core/event/EventBus.h
@@ -28,8 +28,8 @@
#include
#include
-#include "base/std/container/vector.h"
#include "base/Log.h"
+#include "base/std/container/vector.h"
#include "core/memop/Pool.h"
#include "intl/EventIntl.h"
#include "intl/List.h"
diff --git a/native/cocos/core/event/EventTarget.h b/native/cocos/core/event/EventTarget.h
index 64eac3d9b6..3ade2a944d 100644
--- a/native/cocos/core/event/EventTarget.h
+++ b/native/cocos/core/event/EventTarget.h
@@ -647,8 +647,8 @@ public:
constexpr static int __counter_offset__ = 0; \
_DECLARE_TARGET_EVENT_BEGIN(TargetClass)
-#define DECLARE_TARGET_EVENT_BEGIN_WITH_PARENTS(TargetClass, ...) \
- constexpr static int __counter_offset__ = cc::event::intl::TotalEvents<__VA_ARGS__>; \
+#define DECLARE_TARGET_EVENT_BEGIN_WITH_PARENTS(TargetClass, ...) \
+ constexpr static int __counter_offset__ = cc::event::intl::TotalEvents<__VA_ARGS__>; \
_DECLARE_TARGET_EVENT_BEGIN(TargetClass)
#define DECLARE_TARGET_EVENT_END() \
diff --git a/native/cocos/core/event/intl/List.h b/native/cocos/core/event/intl/List.h
index b6542dac27..459b9e67cd 100644
--- a/native/cocos/core/event/intl/List.h
+++ b/native/cocos/core/event/intl/List.h
@@ -21,7 +21,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
- #pragma once
+#pragma once
#include "base/Macros.h"
namespace cc {
@@ -56,7 +56,7 @@ bool detachFromList(ListNode **head, ListNode *node) {
return false;
}
if (node->prev == node && node->next == node) { // the only node
- CC_ASSERT(node == *head); // should be the first
+ CC_ASSERT(node == *head); // should be the first
*head = nullptr;
} else {
auto *nextNode = node->next;
diff --git a/native/cocos/core/geometry/AABB.cpp b/native/cocos/core/geometry/AABB.cpp
index d5c147de5c..898b051d0b 100644
--- a/native/cocos/core/geometry/AABB.cpp
+++ b/native/cocos/core/geometry/AABB.cpp
@@ -172,8 +172,7 @@ void AABB::transformExtentM4(Vec3 *out, const Vec3 &extent, const Mat4 &m4) {
out->transformMat3(extent, m3Tmp);
}
-
-AABB::AABB(float px, float py, float pz, float hw, float hh, float hl):AABB() {
+AABB::AABB(float px, float py, float pz, float hw, float hh, float hl) : AABB() {
setCenter(px, py, pz);
setHalfExtents(hw, hh, hl);
}
diff --git a/native/cocos/core/geometry/AABB.h b/native/cocos/core/geometry/AABB.h
index 8d381602a9..27908df681 100644
--- a/native/cocos/core/geometry/AABB.h
+++ b/native/cocos/core/geometry/AABB.h
@@ -110,7 +110,7 @@ public:
static void transformExtentM4(Vec3 *out, const Vec3 &extent, const Mat4 &m4);
AABB(float px, float py, float pz, float hw, float hh, float hl);
- AABB() : ShapeBase(ShapeEnum::SHAPE_AABB){}
+ AABB() : ShapeBase(ShapeEnum::SHAPE_AABB) {}
~AABB() override = default;
/**
diff --git a/native/cocos/core/geometry/Capsule.h b/native/cocos/core/geometry/Capsule.h
index 20038e7012..20ddbf3572 100644
--- a/native/cocos/core/geometry/Capsule.h
+++ b/native/cocos/core/geometry/Capsule.h
@@ -97,7 +97,7 @@ public:
Vec3 ellipseCenter0;
Vec3 ellipseCenter1;
- explicit Capsule(float radius = 0.5, float halfHeight = 0.5, CenterEnum axis = CenterEnum::Y): ShapeBase(ShapeEnum::SHAPE_CAPSULE) {
+ explicit Capsule(float radius = 0.5, float halfHeight = 0.5, CenterEnum axis = CenterEnum::Y) : ShapeBase(ShapeEnum::SHAPE_CAPSULE) {
this->radius = radius;
this->halfHeight = halfHeight;
this->axis = axis;
diff --git a/native/cocos/core/geometry/Enums.h b/native/cocos/core/geometry/Enums.h
index 1ae914cabb..e6a97c411d 100644
--- a/native/cocos/core/geometry/Enums.h
+++ b/native/cocos/core/geometry/Enums.h
@@ -47,7 +47,6 @@ enum class ShapeEnum {
class ShapeBase : public RefCounted {
public:
-
ShapeBase(ShapeEnum type) : _type(type) {}
/**
diff --git a/native/cocos/core/geometry/Frustum.cpp b/native/cocos/core/geometry/Frustum.cpp
index 8a8bd07dea..c316084673 100644
--- a/native/cocos/core/geometry/Frustum.cpp
+++ b/native/cocos/core/geometry/Frustum.cpp
@@ -176,7 +176,7 @@ void Frustum::updatePlanes() {
planes[5]->define(vertices[7], vertices[5], vertices[6]);
}
-Frustum::Frustum():ShapeBase(ShapeEnum::SHAPE_FRUSTUM) {
+Frustum::Frustum() : ShapeBase(ShapeEnum::SHAPE_FRUSTUM) {
init();
}
diff --git a/native/cocos/core/geometry/Intersect.cpp b/native/cocos/core/geometry/Intersect.cpp
index b23ee0d4db..e8f25a170e 100644
--- a/native/cocos/core/geometry/Intersect.cpp
+++ b/native/cocos/core/geometry/Intersect.cpp
@@ -27,8 +27,8 @@
#include
#include
#include "3d/assets/Mesh.h"
-#include "base/std/container/array.h"
#include "base/TemplateUtils.h"
+#include "base/std/container/array.h"
#include "core/TypedArray.h"
#include "core/geometry/AABB.h"
#include "core/geometry/Capsule.h"
@@ -260,63 +260,63 @@ void fillResult(float *minDis, ERaycastMode m, float d, float i0, float i1, floa
float narrowphase(float *minDis, const Float32Array &vb, const IBArray &ib, gfx::PrimitiveMode pm, const Ray &ray, IRaySubMeshOptions *opt) {
Triangle tri;
auto ibSize = ccstd::visit(overloaded{
- [](const auto &arr) {
- return arr.length();
- },
- [](const ccstd::monostate& /*unused*/) {
- return static_cast(0);
- }
- },
+ [](const auto &arr) {
+ return arr.length();
+ },
+ [](const ccstd::monostate & /*unused*/) {
+ return static_cast(0);
+ }},
ib);
return ccstd::visit(overloaded{[&](const auto &ib) {
- if (pm == gfx::PrimitiveMode::TRIANGLE_LIST) {
- auto cnt = ibSize;
- for (auto j = 0; j < cnt; j += 3) {
- auto i0 = ib[j] * 3;
- auto i1 = ib[j + 1] * 3;
- auto i2 = ib[j + 2] * 3;
- tri.a = {vb[i0], vb[i0 + 1], vb[i0 + 2]};
- tri.b = {vb[i1], vb[i1 + 1], vb[i1 + 2]};
- tri.c = {vb[i2], vb[i2 + 1], vb[i2 + 2]};
- auto dist = rayTriangle(ray, tri, opt->doubleSided);
- if (dist == 0.0F || dist > opt->distance) continue;
- fillResult(minDis, opt->mode, dist, static_cast(i0), static_cast(i1), static_cast(i2), opt->result);
- if (opt->mode == ERaycastMode::ANY) return dist;
- }
- } else if (pm == gfx::PrimitiveMode::TRIANGLE_STRIP) {
- auto cnt = ibSize - 2;
- int32_t rev = 0;
- for (auto j = 0; j < cnt; j += 1) {
- auto i0 = ib[j - rev] * 3;
- auto i1 = ib[j + rev + 1] * 3;
- auto i2 = ib[j + 2] * 3;
- tri.a = {vb[i0], vb[i0 + 1], vb[i0 + 2]};
- tri.b = {vb[i1], vb[i1 + 1], vb[i1 + 2]};
- tri.c = {vb[i2], vb[i2 + 1], vb[i2 + 2]};
- rev = ~rev;
- auto dist = rayTriangle(ray, tri, opt->doubleSided);
- if (dist == 0.0F || dist > opt->distance) continue;
- fillResult(minDis, opt->mode, dist, static_cast(i0), static_cast(i1), static_cast(i2), opt->result);
- if (opt->mode == ERaycastMode::ANY) return dist;
- }
- } else if (pm == gfx::PrimitiveMode::TRIANGLE_FAN) {
- auto cnt = ibSize - 1;
- auto i0 = ib[0] * 3;
- tri.a = {vb[i0], vb[i0 + 1], vb[i0 + 2]};
- for (auto j = 1; j < cnt; j += 1) {
- auto i1 = ib[j] * 3;
- auto i2 = ib[j + 1] * 3;
- tri.b = {vb[i1], vb[i1 + 1], vb[i1 + 2]};
- tri.c = {vb[i2], vb[i2 + 1], vb[i2 + 2]};
- auto dist = rayTriangle(ray, tri, opt->doubleSided);
- if (dist == 0.0 || dist > opt->distance) continue;
- fillResult(minDis, opt->mode, dist, static_cast(i0), static_cast(i1), static_cast(i2), opt->result);
- if (opt->mode == ERaycastMode::ANY) return dist;
- }
- }
- return *minDis;
- }, [](const ccstd::monostate& /*unused*/){ return 0.F; }},
+ if (pm == gfx::PrimitiveMode::TRIANGLE_LIST) {
+ auto cnt = ibSize;
+ for (auto j = 0; j < cnt; j += 3) {
+ auto i0 = ib[j] * 3;
+ auto i1 = ib[j + 1] * 3;
+ auto i2 = ib[j + 2] * 3;
+ tri.a = {vb[i0], vb[i0 + 1], vb[i0 + 2]};
+ tri.b = {vb[i1], vb[i1 + 1], vb[i1 + 2]};
+ tri.c = {vb[i2], vb[i2 + 1], vb[i2 + 2]};
+ auto dist = rayTriangle(ray, tri, opt->doubleSided);
+ if (dist == 0.0F || dist > opt->distance) continue;
+ fillResult(minDis, opt->mode, dist, static_cast(i0), static_cast(i1), static_cast(i2), opt->result);
+ if (opt->mode == ERaycastMode::ANY) return dist;
+ }
+ } else if (pm == gfx::PrimitiveMode::TRIANGLE_STRIP) {
+ auto cnt = ibSize - 2;
+ int32_t rev = 0;
+ for (auto j = 0; j < cnt; j += 1) {
+ auto i0 = ib[j - rev] * 3;
+ auto i1 = ib[j + rev + 1] * 3;
+ auto i2 = ib[j + 2] * 3;
+ tri.a = {vb[i0], vb[i0 + 1], vb[i0 + 2]};
+ tri.b = {vb[i1], vb[i1 + 1], vb[i1 + 2]};
+ tri.c = {vb[i2], vb[i2 + 1], vb[i2 + 2]};
+ rev = ~rev;
+ auto dist = rayTriangle(ray, tri, opt->doubleSided);
+ if (dist == 0.0F || dist > opt->distance) continue;
+ fillResult(minDis, opt->mode, dist, static_cast(i0), static_cast(i1), static_cast(i2), opt->result);
+ if (opt->mode == ERaycastMode::ANY) return dist;
+ }
+ } else if (pm == gfx::PrimitiveMode::TRIANGLE_FAN) {
+ auto cnt = ibSize - 1;
+ auto i0 = ib[0] * 3;
+ tri.a = {vb[i0], vb[i0 + 1], vb[i0 + 2]};
+ for (auto j = 1; j < cnt; j += 1) {
+ auto i1 = ib[j] * 3;
+ auto i2 = ib[j + 1] * 3;
+ tri.b = {vb[i1], vb[i1 + 1], vb[i1 + 2]};
+ tri.c = {vb[i2], vb[i2 + 1], vb[i2 + 2]};
+ auto dist = rayTriangle(ray, tri, opt->doubleSided);
+ if (dist == 0.0 || dist > opt->distance) continue;
+ fillResult(minDis, opt->mode, dist, static_cast(i0), static_cast(i1), static_cast(i2), opt->result);
+ if (opt->mode == ERaycastMode::ANY) return dist;
+ }
+ }
+ return *minDis;
+ },
+ [](const ccstd::monostate & /*unused*/) { return 0.F; }},
ib);
}
} // namespace
diff --git a/native/cocos/core/geometry/Plane.cpp b/native/cocos/core/geometry/Plane.cpp
index f4ea927f51..37d75b4193 100644
--- a/native/cocos/core/geometry/Plane.cpp
+++ b/native/cocos/core/geometry/Plane.cpp
@@ -72,7 +72,7 @@ Plane *Plane::set(Plane *out, float nx, float ny, float nz, float d) {
return out;
}
-Plane::Plane(float nx, float ny, float nz, float d):Plane() {
+Plane::Plane(float nx, float ny, float nz, float d) : Plane() {
n = {nx, ny, nz};
this->d = d;
}
diff --git a/native/cocos/core/geometry/Spec.cpp b/native/cocos/core/geometry/Spec.cpp
index 55bd176110..d3f25096ee 100644
--- a/native/cocos/core/geometry/Spec.cpp
+++ b/native/cocos/core/geometry/Spec.cpp
@@ -21,4 +21,3 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
-
diff --git a/native/cocos/core/geometry/Sphere.cpp b/native/cocos/core/geometry/Sphere.cpp
index c40351512e..c5bdf72df4 100644
--- a/native/cocos/core/geometry/Sphere.cpp
+++ b/native/cocos/core/geometry/Sphere.cpp
@@ -96,7 +96,7 @@ Sphere *Sphere::mergeAABB(Sphere *out, const Sphere &s, const AABB &a) {
return out;
}
-Sphere::Sphere(float cx, float cy, float cz, float radius):ShapeBase(ShapeEnum::SHAPE_SPHERE) {
+Sphere::Sphere(float cx, float cy, float cz, float radius) : ShapeBase(ShapeEnum::SHAPE_SPHERE) {
_center = {cx, cy, cz};
_radius = radius;
}
diff --git a/native/cocos/core/geometry/Sphere.h b/native/cocos/core/geometry/Sphere.h
index db24e92191..e9e523753c 100644
--- a/native/cocos/core/geometry/Sphere.h
+++ b/native/cocos/core/geometry/Sphere.h
@@ -192,7 +192,7 @@ public:
out->_radius = _radius * mathutils::maxComponent(scale);
}
-// private: // make public for js bindings
+ // private: // make public for js bindings
float _radius{-1.0};
Vec3 _center;
};
diff --git a/native/cocos/core/geometry/Triangle.cpp b/native/cocos/core/geometry/Triangle.cpp
index 568067a4ff..07c174cf23 100644
--- a/native/cocos/core/geometry/Triangle.cpp
+++ b/native/cocos/core/geometry/Triangle.cpp
@@ -78,7 +78,7 @@ Triangle *Triangle::set(Triangle *out,
Triangle::Triangle(float ax, float ay, float az,
float bx, float by, float bz,
- float cx, float cy, float cz): ShapeBase(ShapeEnum::SHAPE_TRIANGLE){
+ float cx, float cy, float cz) : ShapeBase(ShapeEnum::SHAPE_TRIANGLE) {
a = {ax, ay, az};
b = {bx, by, bz};
c = {cx, cy, cz};
diff --git a/native/cocos/core/scene-graph/Layers.cpp b/native/cocos/core/scene-graph/Layers.cpp
index 55bd176110..d3f25096ee 100644
--- a/native/cocos/core/scene-graph/Layers.cpp
+++ b/native/cocos/core/scene-graph/Layers.cpp
@@ -21,4 +21,3 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
-
diff --git a/native/cocos/core/scene-graph/SceneGlobals.cpp b/native/cocos/core/scene-graph/SceneGlobals.cpp
index a5a0fe5ae8..c8ff40fa74 100644
--- a/native/cocos/core/scene-graph/SceneGlobals.cpp
+++ b/native/cocos/core/scene-graph/SceneGlobals.cpp
@@ -45,7 +45,7 @@ SceneGlobals::SceneGlobals() {
_bakedWithStationaryMainLight = false;
}
-void SceneGlobals::activate(Scene* scene) {
+void SceneGlobals::activate(Scene *scene) {
auto *sceneData = Root::getInstance()->getPipeline()->getPipelineSceneData();
if (_ambientInfo != nullptr) {
_ambientInfo->activate(sceneData->getAmbient());
diff --git a/native/cocos/editor-support/MeshBuffer.cpp b/native/cocos/editor-support/MeshBuffer.cpp
index 84722a2653..c931d67197 100644
--- a/native/cocos/editor-support/MeshBuffer.cpp
+++ b/native/cocos/editor-support/MeshBuffer.cpp
@@ -134,7 +134,7 @@ void MeshBuffer::reset() {
}
void MeshBuffer::addUIMeshBuffer() {
- UIMeshBuffer* uiMeshBuffer = new UIMeshBuffer();
+ UIMeshBuffer *uiMeshBuffer = new UIMeshBuffer();
ccstd::vector attrs;
if (_vertexFormat == VF_XYZUVC) {
attrs = ATTRIBUTES_V3F_T2F_C4B;
@@ -146,7 +146,7 @@ void MeshBuffer::addUIMeshBuffer() {
}
void MeshBuffer::cleanUIMeshBuffer() {
- for(auto *buf : _uiMeshBufferArr) {
+ for (auto *buf : _uiMeshBufferArr) {
delete buf;
}
_uiMeshBufferArr.clear();
@@ -156,7 +156,7 @@ cc::UIMeshBuffer *MeshBuffer::getUIMeshBuffer() const {
return _uiMeshBufferArr[_bufferPos];
}
-const ccstd::vector& MeshBuffer::uiMeshBuffers() const {
+const ccstd::vector &MeshBuffer::uiMeshBuffers() const {
return _uiMeshBufferArr;
}
diff --git a/native/cocos/editor-support/MeshBuffer.h b/native/cocos/editor-support/MeshBuffer.h
index 821128ed35..a49eea5ee2 100644
--- a/native/cocos/editor-support/MeshBuffer.h
+++ b/native/cocos/editor-support/MeshBuffer.h
@@ -29,7 +29,7 @@
#include "base/std/container/vector.h"
namespace cc {
- class UIMeshBuffer;
+class UIMeshBuffer;
};
MIDDLEWARE_BEGIN
diff --git a/native/cocos/editor-support/MiddlewareManager.cpp b/native/cocos/editor-support/MiddlewareManager.cpp
index 87a930f13e..cad1376e50 100644
--- a/native/cocos/editor-support/MiddlewareManager.cpp
+++ b/native/cocos/editor-support/MiddlewareManager.cpp
@@ -24,8 +24,8 @@
#include "MiddlewareManager.h"
#include
-#include "SeApi.h"
#include "2d/renderer/Batcher2d.h"
+#include "SeApi.h"
#include "core/Root.h"
MIDDLEWARE_BEGIN
@@ -121,7 +121,7 @@ void MiddlewareManager::render(float dt) {
}
uint16_t accID = 65534;
- auto* batch2d = Root::getInstance()->getBatcher2D();
+ auto *batch2d = Root::getInstance()->getBatcher2D();
if (it.first == VF_XYZUVCC) {
accID = 65535;
}
diff --git a/native/cocos/editor-support/dragonbones-creator-support/CCArmatureCacheDisplay.h b/native/cocos/editor-support/dragonbones-creator-support/CCArmatureCacheDisplay.h
index c4bc0b5825..ac02507352 100644
--- a/native/cocos/editor-support/dragonbones-creator-support/CCArmatureCacheDisplay.h
+++ b/native/cocos/editor-support/dragonbones-creator-support/CCArmatureCacheDisplay.h
@@ -36,7 +36,7 @@ namespace cc {
class RenderEntity;
class RenderDrawInfo;
class Material;
-};
+}; // namespace cc
DRAGONBONES_NAMESPACE_BEGIN
@@ -94,7 +94,7 @@ public:
cc::RenderDrawInfo *requestDrawInfo(int idx);
cc::Material *requestMaterial(uint16_t blendSrc, uint16_t blendDst);
void setMaterial(cc::Material *material);
- void setRenderEntity(cc::RenderEntity* entity);
+ void setRenderEntity(cc::RenderEntity *entity);
private:
float _timeScale = 1;
@@ -123,7 +123,7 @@ private:
cc::RenderEntity *_entity = nullptr;
cc::Material *_material = nullptr;
ccstd::vector _drawInfoArray;
- ccstd::unordered_map _materialCaches;
+ ccstd::unordered_map _materialCaches;
};
DRAGONBONES_NAMESPACE_END
diff --git a/native/cocos/editor-support/dragonbones-creator-support/CCArmatureDisplay.h b/native/cocos/editor-support/dragonbones-creator-support/CCArmatureDisplay.h
index 9673561665..4e0e8764c0 100644
--- a/native/cocos/editor-support/dragonbones-creator-support/CCArmatureDisplay.h
+++ b/native/cocos/editor-support/dragonbones-creator-support/CCArmatureDisplay.h
@@ -43,7 +43,7 @@ class RenderEntity;
class RenderDrawInfo;
class Material;
class Texture2D;
-};
+}; // namespace cc
DRAGONBONES_NAMESPACE_BEGIN
@@ -169,7 +169,8 @@ public:
cc::RenderDrawInfo *requestDrawInfo(int idx);
cc::Material *requestMaterial(uint16_t blendSrc, uint16_t blendDst);
void setMaterial(cc::Material *material);
- void setRenderEntity(cc::RenderEntity* entity);
+ void setRenderEntity(cc::RenderEntity *entity);
+
private:
std::map _listenerIDMap;
int _preBlendMode = -1;
@@ -202,7 +203,7 @@ private:
cc::RenderEntity *_entity = nullptr;
cc::Material *_material = nullptr;
ccstd::vector _drawInfoArray;
- ccstd::unordered_map _materialCaches;
+ ccstd::unordered_map _materialCaches;
};
DRAGONBONES_NAMESPACE_END
diff --git a/native/cocos/editor-support/middleware-adapter.cpp b/native/cocos/editor-support/middleware-adapter.cpp
index 250c122c98..3665028ec8 100644
--- a/native/cocos/editor-support/middleware-adapter.cpp
+++ b/native/cocos/editor-support/middleware-adapter.cpp
@@ -105,7 +105,7 @@ void Texture2D::setTexParameters(const TexParams &texParams) {
}
}
-void Texture2D::setRealTexture(void* texturePtr) {
+void Texture2D::setRealTexture(void *texturePtr) {
_texturePtr = texturePtr;
}
diff --git a/native/cocos/editor-support/middleware-adapter.h b/native/cocos/editor-support/middleware-adapter.h
index a99c59ee0e..c9ae620f6a 100644
--- a/native/cocos/editor-support/middleware-adapter.h
+++ b/native/cocos/editor-support/middleware-adapter.h
@@ -180,8 +180,9 @@ public:
/** Sets texture param callback*/
void setTexParamCallback(const texParamCallback &callback);
- void setRealTexture(void* texturePtr);
+ void setRealTexture(void *texturePtr);
void *getRealTexture() const;
+
private:
/** width in pixels */
int _pixelsWide = 0;
@@ -193,7 +194,7 @@ private:
int _realTextureIndex = 0;
texParamCallback _texParamCallback = nullptr;
- void* _texturePtr = nullptr;
+ void *_texturePtr = nullptr;
};
///////////////////////////////////////////////////////////////////////
diff --git a/native/cocos/engine/EngineEvents.h b/native/cocos/engine/EngineEvents.h
index 4d05ffa231..b9f62dee06 100644
--- a/native/cocos/engine/EngineEvents.h
+++ b/native/cocos/engine/EngineEvents.h
@@ -292,8 +292,7 @@ public:
Type type{Type::UNKNOWN}; // NOLINT(modernize-use-nullptr)
};
-
-enum class ScriptEngineEvent{
+enum class ScriptEngineEvent {
BEFORE_INIT,
AFTER_INIT,
BEFORE_CLEANUP,
diff --git a/native/cocos/network/Downloader-curl.cpp b/native/cocos/network/Downloader-curl.cpp
index ef65078231..e120843a62 100644
--- a/native/cocos/network/Downloader-curl.cpp
+++ b/native/cocos/network/Downloader-curl.cpp
@@ -36,8 +36,8 @@
#include "base/std/container/deque.h"
#include "base/std/container/set.h"
#include "base/std/container/vector.h"
-#include "platform/FileUtils.h"
#include "network/Downloader.h"
+#include "platform/FileUtils.h"
// **NOTE**
// In the file:
diff --git a/native/cocos/network/Downloader-java.cpp b/native/cocos/network/Downloader-java.cpp
index 85a6990359..c67075be2b 100644
--- a/native/cocos/network/Downloader-java.cpp
+++ b/native/cocos/network/Downloader-java.cpp
@@ -27,11 +27,11 @@
#include
#include "application/ApplicationManager.h"
+#include "base/StringUtil.h"
#include "base/memory/Memory.h"
#include "network/Downloader.h"
#include "platform/java/jni/JniHelper.h"
#include "platform/java/jni/JniImp.h"
-#include "base/StringUtil.h"
#ifndef JCLS_DOWNLOADER
#define JCLS_DOWNLOADER "com/cocos/lib/CocosDownloader"
diff --git a/native/cocos/network/WebSocketServer.cpp b/native/cocos/network/WebSocketServer.cpp
index 1eb37568e1..3e742f9aeb 100644
--- a/native/cocos/network/WebSocketServer.cpp
+++ b/native/cocos/network/WebSocketServer.cpp
@@ -590,7 +590,7 @@ ccstd::unordered_map WebSocketServerConnection::ge
}
int WebSocketServer::websocketServerCallback(struct lws *wsi, enum lws_callback_reasons reason,
- void * /*user*/, void *in, size_t len) {
+ void * /*user*/, void *in, size_t len) {
int ret = 0;
WebSocketServer *server = nullptr;
lws_context *ctx = nullptr;
diff --git a/native/cocos/network/WebSocketServer.h b/native/cocos/network/WebSocketServer.h
index f93afb9b99..8bb6a8db3f 100644
--- a/native/cocos/network/WebSocketServer.h
+++ b/native/cocos/network/WebSocketServer.h
@@ -291,7 +291,7 @@ private:
public:
static int websocketServerCallback(struct lws *wsi, enum lws_callback_reasons reason,
- void *user, void *in, size_t len);
+ void *user, void *in, size_t len);
};
} // namespace network
} // namespace cc
diff --git a/native/cocos/physics/physx/PhysX.h b/native/cocos/physics/physx/PhysX.h
index 45af25326f..31b87c06d0 100644
--- a/native/cocos/physics/physx/PhysX.h
+++ b/native/cocos/physics/physx/PhysX.h
@@ -37,6 +37,6 @@
#include "physics/physx/shapes/PhysXTerrain.h"
#include "physics/physx/shapes/PhysXTrimesh.h"
-#include "physics/physx/joints/PhysXSpherical.h"
-#include "physics/physx/joints/PhysXRevolute.h"
#include "physics/physx/joints/PhysXFixedJoint.h"
+#include "physics/physx/joints/PhysXRevolute.h"
+#include "physics/physx/joints/PhysXSpherical.h"
diff --git a/native/cocos/physics/physx/joints/PhysXSpherical.h b/native/cocos/physics/physx/joints/PhysXSpherical.h
index 963b069d2d..67a9b0aaf2 100644
--- a/native/cocos/physics/physx/joints/PhysXSpherical.h
+++ b/native/cocos/physics/physx/joints/PhysXSpherical.h
@@ -32,7 +32,7 @@ namespace physics {
class PhysXSpherical final : public PhysXJoint, public IDistanceJoint {
public:
PhysXSpherical() : _mPivotA(physx::PxZero),
- _mPivotB(physx::PxZero){};
+ _mPivotB(physx::PxZero){};
~PhysXSpherical() override = default;
void setPivotA(float x, float y, float z) override;
diff --git a/native/cocos/physics/sdk/Joint.h b/native/cocos/physics/sdk/Joint.h
index ba1ed02e90..b093668cc0 100644
--- a/native/cocos/physics/sdk/Joint.h
+++ b/native/cocos/physics/sdk/Joint.h
@@ -62,7 +62,8 @@ void setPivotB(float x, float y, float z) override;
CC_PHYSICS_JOINT_CLASS(FixedJoint)
void setBreakForce(float force) override;
void setBreakTorque(float torque) override;
-}; // FixedJoint
+}
+; // FixedJoint
} // namespace physics
} // namespace cc
diff --git a/native/cocos/platform/Image.cpp b/native/cocos/platform/Image.cpp
index 47a7235248..5a195002a5 100644
--- a/native/cocos/platform/Image.cpp
+++ b/native/cocos/platform/Image.cpp
@@ -53,8 +53,8 @@ extern "C" {
#include "base/etc2.h"
}
-#include "base/astc.h"
#include "base/Compressed.h"
+#include "base/astc.h"
#if CC_USE_WEBP
#include "webp/decode.h"
@@ -287,7 +287,7 @@ bool Image::initWithImageFile(const ccstd::string &path) {
return ret;
}
-bool Image::initWithImageData(const unsigned char *data, uint32_t dataLen) { //NOLINT(misc-no-recursion)
+bool Image::initWithImageData(const unsigned char *data, uint32_t dataLen) { //NOLINT(misc-no-recursion)
bool ret = false;
do {
CC_BREAK_IF(!data || dataLen <= 0);
@@ -883,7 +883,7 @@ bool Image::initWithASTCData(const unsigned char *data, uint32_t dataLen) {
return true;
}
-bool Image::initWithCompressedMipsData(const unsigned char *data, uint32_t /*dataLen*/) { //NOLINT(misc-no-recursion)
+bool Image::initWithCompressedMipsData(const unsigned char *data, uint32_t /*dataLen*/) { //NOLINT(misc-no-recursion)
//check the data
if (!compressedIsValid(data)) {
return false;
diff --git a/native/cocos/platform/SDLHelper.h b/native/cocos/platform/SDLHelper.h
index 7e7f9eaa89..8089d74be3 100644
--- a/native/cocos/platform/SDLHelper.h
+++ b/native/cocos/platform/SDLHelper.h
@@ -54,7 +54,7 @@ public:
static void setCursorEnabled(bool value);
private:
- static void dispatchSDLEvent( uint32_t windowId, const SDL_Event& sdlEvent, bool* quit);
+ static void dispatchSDLEvent(uint32_t windowId, const SDL_Event& sdlEvent, bool* quit);
static void dispatchWindowEvent(uint32_t windowId, const SDL_WindowEvent& wevent);
};
} // namespace cc
diff --git a/native/cocos/platform/empty/EmptyPlatform.cpp b/native/cocos/platform/empty/EmptyPlatform.cpp
index 88d6ffc860..7b247e8c87 100644
--- a/native/cocos/platform/empty/EmptyPlatform.cpp
+++ b/native/cocos/platform/empty/EmptyPlatform.cpp
@@ -23,7 +23,6 @@
****************************************************************************/
#include "platform/empty/EmptyPlatform.h"
-#include "platform/interfaces/OSInterface.h"
#include "modules/Accelerometer.h"
#include "modules/Battery.h"
#include "modules/Network.h"
@@ -31,6 +30,7 @@
#include "modules/System.h"
#include "modules/SystemWindow.h"
#include "modules/Vibrator.h"
+#include "platform/interfaces/OSInterface.h"
#include
#include
diff --git a/native/cocos/platform/empty/modules/SystemWindowManager.cpp b/native/cocos/platform/empty/modules/SystemWindowManager.cpp
index 8bf4aab093..e8a09cb61d 100644
--- a/native/cocos/platform/empty/modules/SystemWindowManager.cpp
+++ b/native/cocos/platform/empty/modules/SystemWindowManager.cpp
@@ -24,8 +24,8 @@
#include "SystemWindowManager.h"
#include "platform/BasePlatform.h"
-#include "platform/interfaces/modules/ISystemWindowManager.h"
#include "platform/empty/modules/SystemWindow.h"
+#include "platform/interfaces/modules/ISystemWindowManager.h"
namespace cc {
@@ -33,8 +33,7 @@ int SystemWindowManager::init() {
return 0;
}
-void SystemWindowManager::processEvent(bool* quit) {
-
+void SystemWindowManager::processEvent(bool *quit) {
}
ISystemWindow *SystemWindowManager::getWindow(uint32_t windowId) const {
diff --git a/native/cocos/platform/empty/modules/SystemWindowManager.h b/native/cocos/platform/empty/modules/SystemWindowManager.h
index dfc2d49a46..30394b95db 100644
--- a/native/cocos/platform/empty/modules/SystemWindowManager.h
+++ b/native/cocos/platform/empty/modules/SystemWindowManager.h
@@ -27,7 +27,6 @@
#include "base/std/container/unordered_map.h"
#include "platform/interfaces/modules/ISystemWindowManager.h"
-
namespace cc {
class ISystemWindow;
@@ -37,7 +36,7 @@ public:
explicit SystemWindowManager() = default;
int init() override;
- void processEvent(bool* quit) override;
+ void processEvent(bool *quit) override;
ISystemWindow *createWindow(const ISystemWindowInfo &info) override;
ISystemWindow *getWindow(uint32_t windowId) const override;
diff --git a/native/cocos/platform/interfaces/OSInterface.h b/native/cocos/platform/interfaces/OSInterface.h
index 32278567d3..c62b596222 100644
--- a/native/cocos/platform/interfaces/OSInterface.h
+++ b/native/cocos/platform/interfaces/OSInterface.h
@@ -43,7 +43,6 @@ public:
*/
virtual ~OSInterface() = default;
-
private:
CC_DISALLOW_COPY_MOVE_ASSIGN(OSInterface);
};
diff --git a/native/cocos/platform/interfaces/modules/XRCommon.h b/native/cocos/platform/interfaces/modules/XRCommon.h
index a970c2ab07..c0d5cccd41 100644
--- a/native/cocos/platform/interfaces/modules/XRCommon.h
+++ b/native/cocos/platform/interfaces/modules/XRCommon.h
@@ -69,7 +69,7 @@ enum class XRConfigKey {
PRESENT_ENABLE = 15,
RENDER_EYE_FRAME_LEFT = 16,
RENDER_EYE_FRAME_RIGHT = 17,
- FEATURE_PASSTHROUGH= 18,
+ FEATURE_PASSTHROUGH = 18,
IMAGE_TRACKING = 19,
IMAGE_TRACKING_CANDIDATEIMAGE = 20,
IMAGE_TRACKING_DATA = 21,
@@ -331,16 +331,16 @@ struct XRSwapchain {
};
struct XRTrackingImageData {
- std::string friendlyName;
- uint32_t id;
- uint8_t *buffer;
- uint32_t bufferSize;
- float physicalWidth;
- float physicalHeight;
- uint32_t pixelSizeWidth;
- uint32_t pixelSizeHeight;
- float posePosition[3];
- float poseQuaternion[4];
+ std::string friendlyName;
+ uint32_t id;
+ uint8_t *buffer;
+ uint32_t bufferSize;
+ float physicalWidth;
+ float physicalHeight;
+ uint32_t pixelSizeWidth;
+ uint32_t pixelSizeHeight;
+ float posePosition[3];
+ float poseQuaternion[4];
};
#define GraphicsApiOpenglES "OpenGLES"
diff --git a/native/cocos/platform/interfaces/modules/canvas/CanvasRenderingContext2D.cpp b/native/cocos/platform/interfaces/modules/canvas/CanvasRenderingContext2D.cpp
index cd142b3112..c9ec6c7d3f 100644
--- a/native/cocos/platform/interfaces/modules/canvas/CanvasRenderingContext2D.cpp
+++ b/native/cocos/platform/interfaces/modules/canvas/CanvasRenderingContext2D.cpp
@@ -310,8 +310,8 @@ void CanvasRenderingContext2D::setFont(const ccstd::string &font) {
double fontSize = atof(fontSizeStr.c_str());
bool isBold = font.find("bold", 0) != ccstd::string::npos || font.find("Bold", 0) != ccstd::string::npos;
bool isItalic = font.find("italic", 0) != ccstd::string::npos || font.find("Italic", 0) != ccstd::string::npos;
- bool isSmallCaps = font.find("small-caps", 0) != ccstd::string::npos || font.find("Small-Caps") !=ccstd::string::npos;
- bool isOblique = font.find("oblique", 0) != ccstd::string::npos || font.find("Oblique", 0) != ccstd::string::npos ;
+ bool isSmallCaps = font.find("small-caps", 0) != ccstd::string::npos || font.find("Small-Caps") != ccstd::string::npos;
+ bool isOblique = font.find("oblique", 0) != ccstd::string::npos || font.find("Oblique", 0) != ccstd::string::npos;
//font-style: italic, oblique, normal
//font-weight: normal, bold
//font-variant: normal, small-caps
diff --git a/native/cocos/platform/ios/AppDelegateBridge.h b/native/cocos/platform/ios/AppDelegateBridge.h
index 806e9aff77..e2515c9465 100644
--- a/native/cocos/platform/ios/AppDelegateBridge.h
+++ b/native/cocos/platform/ios/AppDelegateBridge.h
@@ -24,9 +24,9 @@
#pragma once
-#include "platform/UniversalPlatform.h"
#import
#import
+#include "platform/UniversalPlatform.h"
@interface AppDelegateBridge : NSObject
- (float)getPixelRatio;
diff --git a/native/cocos/platform/java/jni/JniCocosOrientationHelper.cpp b/native/cocos/platform/java/jni/JniCocosOrientationHelper.cpp
index f7600b22bd..804be6d067 100644
--- a/native/cocos/platform/java/jni/JniCocosOrientationHelper.cpp
+++ b/native/cocos/platform/java/jni/JniCocosOrientationHelper.cpp
@@ -64,6 +64,4 @@ JNIEXPORT void JNICALL Java_com_cocos_lib_CocosAbilitySlice_onOrientationChanged
pWidth = width;
}
}
-
-
}
diff --git a/native/cocos/platform/java/jni/JniHelper.cpp b/native/cocos/platform/java/jni/JniHelper.cpp
index 37003eaacc..67a0681ef9 100644
--- a/native/cocos/platform/java/jni/JniHelper.cpp
+++ b/native/cocos/platform/java/jni/JniHelper.cpp
@@ -138,8 +138,8 @@ void JniHelper::init(JNIEnv *env, jobject activity) {
}
void JniHelper::onDestroy() {
- if(JniHelper::sJavaVM) {
- if(JniHelper::sActivity) {
+ if (JniHelper::sJavaVM) {
+ if (JniHelper::sActivity) {
cc::JniHelper::getEnv()->DeleteGlobalRef(JniHelper::sActivity);
JniHelper::sActivity = nullptr;
}
@@ -198,7 +198,7 @@ jobject JniHelper::getActivity() {
#if CC_PLATFORM == CC_PLATFORM_OHOS
bool JniHelper::setClassLoaderFrom(jobject activityinstance) {
- if(!JniHelper::classloader) {
+ if (!JniHelper::classloader) {
JniMethodInfo getclassloaderMethod;
if (!JniHelper::getMethodInfoDefaultClassLoader(getclassloaderMethod,
"ohos/app/AbilityContext",
diff --git a/native/cocos/platform/java/jni/glue/JniNativeGlue.cpp b/native/cocos/platform/java/jni/glue/JniNativeGlue.cpp
index 6bb756cab5..8e1df8dd10 100644
--- a/native/cocos/platform/java/jni/glue/JniNativeGlue.cpp
+++ b/native/cocos/platform/java/jni/glue/JniNativeGlue.cpp
@@ -25,6 +25,7 @@
#include "platform/java/jni/glue/JniNativeGlue.h"
#include
#include
+#include "application/ApplicationManager.h"
#include "engine/EngineEvents.h"
#include "platform/BasePlatform.h"
#include "platform/java/jni/JniImp.h"
@@ -32,7 +33,6 @@
#include "platform/java/jni/log.h"
#include "platform/java/modules/SystemWindow.h"
#include "platform/java/modules/SystemWindowManager.h"
-#include "application/ApplicationManager.h"
namespace cc {
JniNativeGlue::~JniNativeGlue() = default;
@@ -217,9 +217,9 @@ void JniNativeGlue::engineHandleCmd(JniCommand cmd) {
switch (cmd) {
case JniCommand::JNI_CMD_INIT_WINDOW: {
if (isWindowInitialized) {
- return;
- }
- isWindowInitialized = true;
+ return;
+ }
+ isWindowInitialized = true;
// cc::CustomEvent event;
// event.name = EVENT_RECREATE_WINDOW;
// event.args->ptrVal = reinterpret_cast(getWindowHandle());
@@ -228,7 +228,7 @@ void JniNativeGlue::engineHandleCmd(JniCommand cmd) {
info.height = getHeight();
info.externalHandle = getWindowHandle();
BasePlatform* platform = cc::BasePlatform::getPlatform();
- auto *windowMgr = platform->getInterface();
+ auto* windowMgr = platform->getInterface();
CC_ASSERT(windowMgr != nullptr);
windowMgr->createWindow(info);
events::WindowRecreated::broadcast(ISystemWindow::mainWindowId);
diff --git a/native/cocos/platform/java/modules/SystemWindow.h b/native/cocos/platform/java/modules/SystemWindow.h
index 9c4f4dc414..53fc471f6f 100644
--- a/native/cocos/platform/java/modules/SystemWindow.h
+++ b/native/cocos/platform/java/modules/SystemWindow.h
@@ -24,8 +24,8 @@
#pragma once
-#include
#include
+#include
#include "platform/interfaces/modules/ISystemWindow.h"
namespace cc {
diff --git a/native/cocos/platform/java/modules/SystemWindowManager.cpp b/native/cocos/platform/java/modules/SystemWindowManager.cpp
index 0364176721..a2e79fe22d 100644
--- a/native/cocos/platform/java/modules/SystemWindowManager.cpp
+++ b/native/cocos/platform/java/modules/SystemWindowManager.cpp
@@ -28,7 +28,6 @@
namespace cc {
-
int SystemWindowManager::init() {
return 0;
}
diff --git a/native/cocos/platform/java/modules/XRInterface.cpp b/native/cocos/platform/java/modules/XRInterface.cpp
index 1e2937d24b..1097c84bcf 100644
--- a/native/cocos/platform/java/modules/XRInterface.cpp
+++ b/native/cocos/platform/java/modules/XRInterface.cpp
@@ -27,10 +27,10 @@
#include
#include
#include
-#include "base/StringUtil.h"
#include "android/AndroidPlatform.h"
#include "base/Log.h"
#include "base/Macros.h"
+#include "base/StringUtil.h"
#include "bindings/event/EventDispatcher.h"
#include "cocos/bindings/jswrapper/SeApi.h"
#include "java/jni/JniHelper.h"
@@ -443,8 +443,8 @@ void XRInterface::initialize(void *javaVM, void *activity) {
if (value.getInt() == 1) {
this->endRenderEyeFrame(key == xr::XRConfigKey::RENDER_EYE_FRAME_LEFT ? 0 : 1);
}
- } else if(key == xr::XRConfigKey::IMAGE_TRACKING_CANDIDATEIMAGE && value.isString()) {
- if(!_gThreadPool) {
+ } else if (key == xr::XRConfigKey::IMAGE_TRACKING_CANDIDATEIMAGE && value.isString()) {
+ if (!_gThreadPool) {
_gThreadPool = LegacyThreadPool::newSingleThreadPool();
}
diff --git a/native/cocos/platform/java/modules/XRInterface.h b/native/cocos/platform/java/modules/XRInterface.h
index 3cdcc2d4b0..8edcf0ae0a 100644
--- a/native/cocos/platform/java/modules/XRInterface.h
+++ b/native/cocos/platform/java/modules/XRInterface.h
@@ -28,7 +28,7 @@
#include "base/ThreadPool.h"
#include "platform/interfaces/modules/IXRInterface.h"
#if CC_USE_XR_REMOTE_PREVIEW
-#include "xr/XRRemotePreviewManager.h"
+ #include "xr/XRRemotePreviewManager.h"
#endif
namespace se {
class Object;
@@ -100,12 +100,12 @@ public:
void bindXREyeWithRenderWindow(void *window, xr::XREye eye) override;
private:
- void loadAssetsImage(const std::string &imageInfo);
- void dispatchGamepadEventInternal(const xr::XRControllerEvent &xrControllerEvent);
- void dispatchHandleEventInternal(const xr::XRControllerEvent &xrControllerEvent);
- void dispatchHMDEventInternal(const xr::XRControllerEvent &xrControllerEvent);
- ControllerEvent _controllerEvent;
- se::Object *_jsPoseEventArray{nullptr};
+ void loadAssetsImage(const std::string &imageInfo);
+ void dispatchGamepadEventInternal(const xr::XRControllerEvent &xrControllerEvent);
+ void dispatchHandleEventInternal(const xr::XRControllerEvent &xrControllerEvent);
+ void dispatchHMDEventInternal(const xr::XRControllerEvent &xrControllerEvent);
+ ControllerEvent _controllerEvent;
+ se::Object *_jsPoseEventArray{nullptr};
#if CC_USE_VULKAN
PFN_vkGetInstanceProcAddr _vkGetInstanceProcAddr{nullptr};
diff --git a/native/cocos/platform/ohos/OhosPlatform.h b/native/cocos/platform/ohos/OhosPlatform.h
index 3e8dcc6294..c678c58bac 100644
--- a/native/cocos/platform/ohos/OhosPlatform.h
+++ b/native/cocos/platform/ohos/OhosPlatform.h
@@ -37,6 +37,7 @@ public:
int getSdkVersion() const override;
int32_t loop() override;
ISystemWindow *createNativeWindow(uint32_t windowId, void *externalHandle) override;
+
private:
void waitWindowInitialized();
diff --git a/native/cocos/plugins/bus/EventBus.h b/native/cocos/plugins/bus/EventBus.h
index 7912f78f5e..d505d9fa5d 100644
--- a/native/cocos/plugins/bus/EventBus.h
+++ b/native/cocos/plugins/bus/EventBus.h
@@ -165,7 +165,7 @@ private:
void dispatch(EventBase *event);
void addListener(Listener *);
void removeListener(Listener *);
- std::vector _listeners;
+ std::vector _listeners;
friend class Listener;
};
diff --git a/native/cocos/primitive/PrimitiveUtils.cpp b/native/cocos/primitive/PrimitiveUtils.cpp
index 55bd176110..d3f25096ee 100644
--- a/native/cocos/primitive/PrimitiveUtils.cpp
+++ b/native/cocos/primitive/PrimitiveUtils.cpp
@@ -21,4 +21,3 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
-
diff --git a/native/cocos/renderer/GFXDeviceManager.h b/native/cocos/renderer/GFXDeviceManager.h
index a15f745ea5..c43385a47a 100644
--- a/native/cocos/renderer/GFXDeviceManager.h
+++ b/native/cocos/renderer/GFXDeviceManager.h
@@ -38,7 +38,7 @@
// arengine only supports gles2, arcore supports gles2 and gles3
// setting the CC_USE_GLES3 off is needed while using CC_USE_AR_AUTO or CC_USE_AR_ENGINE
#if CC_USE_AR_MODULE && (CC_USE_AR_AUTO || CC_USE_AR_ENGINE)
-#undef CC_USE_GLES3
+ #undef CC_USE_GLES3
#endif
#ifdef CC_USE_NVN
@@ -105,7 +105,7 @@ public:
#endif
#ifdef CC_USE_GLES2
- // arcore & arengine currently only supports gles, session update requires gl context
+ // arcore & arengine currently only supports gles, session update requires gl context
#if CC_USE_AR_MODULE
Device::isSupportDetachDeviceThread = false;
#endif
diff --git a/native/cocos/renderer/core/PassUtils.cpp b/native/cocos/renderer/core/PassUtils.cpp
index 5953f4da46..da7953b34d 100644
--- a/native/cocos/renderer/core/PassUtils.cpp
+++ b/native/cocos/renderer/core/PassUtils.cpp
@@ -193,7 +193,6 @@ const ccstd::unordered_map type2writer = {
}},
};
-
const ccstd::unordered_map type2validator = {
{gfx::Type::UNKNOWN, [](const MaterialProperty & /*v*/) -> bool {
CC_LOG_ERROR("type2validator unknown type");
diff --git a/native/cocos/renderer/core/PassUtils.h b/native/cocos/renderer/core/PassUtils.h
index 95e8c93f71..5bafe6911b 100644
--- a/native/cocos/renderer/core/PassUtils.h
+++ b/native/cocos/renderer/core/PassUtils.h
@@ -85,8 +85,8 @@ using GFXTypeReaderCallback = void (*)(const float *, MaterialProperty &, index_
using GFXTypeWriterCallback = void (*)(float *, const MaterialProperty &, index_t);
using GFXTypeValidatorCallback = bool (*)(const MaterialProperty &);
-extern const ccstd::unordered_map type2reader; //NOLINT(readability-identifier-naming)
-extern const ccstd::unordered_map type2writer; //NOLINT(readability-identifier-naming)
+extern const ccstd::unordered_map type2reader; //NOLINT(readability-identifier-naming)
+extern const ccstd::unordered_map type2writer; //NOLINT(readability-identifier-naming)
extern const ccstd::unordered_map type2validator; //NOLINT(readability-identifier-naming)
/**
diff --git a/native/cocos/renderer/gfx-agent/BufferAgent.cpp b/native/cocos/renderer/gfx-agent/BufferAgent.cpp
index 4b68e28262..ec593a7282 100644
--- a/native/cocos/renderer/gfx-agent/BufferAgent.cpp
+++ b/native/cocos/renderer/gfx-agent/BufferAgent.cpp
@@ -86,8 +86,7 @@ void BufferAgent::doResize(uint32_t size, uint32_t /*count*/) {
ENQUEUE_MESSAGE_1(
mq, BufferFreeStagingBuffer,
stagingBuffer, std::move(_stagingBuffer),
- {
- });
+ {});
}
if (hasFlag(_flags, BufferFlagBit::ENABLE_STAGING_WRITE) || (size > STAGING_BUFFER_THRESHOLD && hasFlag(_memUsage, MemoryUsageBit::HOST))) {
diff --git a/native/cocos/renderer/gfx-agent/DeviceAgent.cpp b/native/cocos/renderer/gfx-agent/DeviceAgent.cpp
index 98e1c7d8e7..5f9f3749ec 100644
--- a/native/cocos/renderer/gfx-agent/DeviceAgent.cpp
+++ b/native/cocos/renderer/gfx-agent/DeviceAgent.cpp
@@ -24,10 +24,10 @@
#include
#include
+#include "application/ApplicationManager.h"
#include "base/Log.h"
#include "base/threading/MessageQueue.h"
#include "base/threading/ThreadSafeLinearAllocator.h"
-#include "application/ApplicationManager.h"
#include "platform/interfaces/modules/IXRInterface.h"
#include "BufferAgent.h"
diff --git a/native/cocos/renderer/gfx-base/GFXBuffer.h b/native/cocos/renderer/gfx-base/GFXBuffer.h
index 8beb5463d3..715b983078 100644
--- a/native/cocos/renderer/gfx-base/GFXBuffer.h
+++ b/native/cocos/renderer/gfx-base/GFXBuffer.h
@@ -43,8 +43,8 @@ public:
void destroy();
template
- void write(const T& value, uint32_t offset) const {
- write(reinterpret_cast(&value), offset, sizeof(T));
+ void write(const T &value, uint32_t offset) const {
+ write(reinterpret_cast(&value), offset, sizeof(T));
}
void write(const uint8_t *value, uint32_t offset, uint32_t size) const;
@@ -72,7 +72,7 @@ protected:
static uint8_t *getBufferStagingAddress(Buffer *buffer);
static void flushBuffer(Buffer *buffer, const uint8_t *data);
- virtual void flush(const uint8_t *data) { update(reinterpret_cast(data), _size); }
+ virtual void flush(const uint8_t *data) { update(reinterpret_cast(data), _size); }
virtual uint8_t *getStagingAddress() const { return _data.get(); }
BufferUsage _usage = BufferUsageBit::NONE;
diff --git a/native/cocos/renderer/gfx-base/GFXDescriptorSet.cpp b/native/cocos/renderer/gfx-base/GFXDescriptorSet.cpp
index c05ad36ce7..2c9f263081 100644
--- a/native/cocos/renderer/gfx-base/GFXDescriptorSet.cpp
+++ b/native/cocos/renderer/gfx-base/GFXDescriptorSet.cpp
@@ -23,11 +23,11 @@
****************************************************************************/
#include "GFXDescriptorSet.h"
-#include "GFXDescriptorSetLayout.h"
#include "GFXBuffer.h"
+#include "GFXDescriptorSetLayout.h"
+#include "GFXObject.h"
#include "GFXTexture.h"
#include "states/GFXSampler.h"
-#include "GFXObject.h"
namespace cc {
namespace gfx {
diff --git a/native/cocos/renderer/gfx-base/GFXDevice.cpp b/native/cocos/renderer/gfx-base/GFXDevice.cpp
index dab6a4a2fb..8a63f30b56 100644
--- a/native/cocos/renderer/gfx-base/GFXDevice.cpp
+++ b/native/cocos/renderer/gfx-base/GFXDevice.cpp
@@ -130,14 +130,14 @@ DefaultResource::DefaultResource(Device *device) {
ccstd::vector buffer(bufferSize, 255);
const uint8_t *bufferData = buffer.data();
if (device->getCapabilities().maxTextureSize >= 2) {
- _texture2D = device->createTexture({TextureType::TEX2D, TextureUsageBit::STORAGE | TextureUsageBit::SAMPLED,
- Format::RGBA8, 2, 2, TextureFlagBit::NONE});
+ _texture2D = device->createTexture({TextureType::TEX2D, TextureUsageBit::STORAGE | TextureUsageBit::SAMPLED,
+ Format::RGBA8, 2, 2, TextureFlagBit::NONE});
BufferTextureCopy region = {0, 0, 0, {0, 0, 0}, {2, 2, 1}, {0, 0, 1}};
device->copyBuffersToTexture(&bufferData, _texture2D, ®ion, 1);
}
if (device->getCapabilities().maxTextureSize >= 2) {
_textureCube = device->createTexture({TextureType::CUBE, TextureUsageBit::STORAGE | TextureUsageBit::SAMPLED,
- Format::RGBA8, 2, 2, TextureFlagBit::NONE, 6});
+ Format::RGBA8, 2, 2, TextureFlagBit::NONE, 6});
BufferTextureCopy region = {0, 0, 0, {0, 0, 0}, {2, 2, 1}, {0, 0, 1}};
device->copyBuffersToTexture(&bufferData, _textureCube, ®ion, 1);
region.texSubres.baseArrayLayer = 1;
@@ -154,13 +154,13 @@ DefaultResource::DefaultResource(Device *device) {
if (device->getCapabilities().max3DTextureSize >= 2) {
_texture3D = device->createTexture({TextureType::TEX3D, TextureUsageBit::STORAGE | TextureUsageBit::SAMPLED,
- Format::RGBA8, 2, 2, TextureFlagBit::NONE, 1, 1, SampleCount::ONE, 2});
+ Format::RGBA8, 2, 2, TextureFlagBit::NONE, 1, 1, SampleCount::ONE, 2});
BufferTextureCopy region = {0, 0, 0, {0, 0, 0}, {2, 2, 2}, {0, 0, 1}};
device->copyBuffersToTexture(&bufferData, _texture3D, ®ion, 1);
}
if (device->getCapabilities().maxArrayTextureLayers >= 2) {
_texture1DArray = device->createTexture({TextureType::TEX1D_ARRAY, TextureUsageBit::STORAGE | TextureUsageBit::SAMPLED,
- Format::RGBA8, 1, 1, TextureFlagBit::NONE, 2});
+ Format::RGBA8, 1, 1, TextureFlagBit::NONE, 2});
BufferTextureCopy region = {0, 0, 0, {0, 0, 0}, {1, 1, 1}, {0, 0, 1}};
device->copyBuffersToTexture(&bufferData, _texture1DArray, ®ion, 1);
region.texSubres.baseArrayLayer = 1;
@@ -168,7 +168,7 @@ DefaultResource::DefaultResource(Device *device) {
}
if (device->getCapabilities().maxArrayTextureLayers >= 2) {
_texture2DArray = device->createTexture({TextureType::TEX2D_ARRAY, TextureUsageBit::STORAGE | TextureUsageBit::SAMPLED,
- Format::RGBA8, 2, 2, TextureFlagBit::NONE, 2});
+ Format::RGBA8, 2, 2, TextureFlagBit::NONE, 2});
BufferTextureCopy region = {0, 0, 0, {0, 0, 0}, {2, 2, 1}, {0, 0, 1}};
device->copyBuffersToTexture(&bufferData, _texture2DArray, ®ion, 1);
region.texSubres.baseArrayLayer = 1;
diff --git a/native/cocos/renderer/gfx-base/GFXDeviceObject.h b/native/cocos/renderer/gfx-base/GFXDeviceObject.h
index 110c7d62cf..7c487daf7e 100644
--- a/native/cocos/renderer/gfx-base/GFXDeviceObject.h
+++ b/native/cocos/renderer/gfx-base/GFXDeviceObject.h
@@ -22,9 +22,9 @@ Permission is hereby granted, free of charge, to any person obtaining a copy
#pragma once
-#include "base/Ptr.h"
-#include "base/Macros.h"
#include
+#include "base/Macros.h"
+#include "base/Ptr.h"
namespace cc {
namespace gfx {
diff --git a/native/cocos/renderer/gfx-base/GFXTexture.cpp b/native/cocos/renderer/gfx-base/GFXTexture.cpp
index fbdac18634..d8b6a7cde0 100644
--- a/native/cocos/renderer/gfx-base/GFXTexture.cpp
+++ b/native/cocos/renderer/gfx-base/GFXTexture.cpp
@@ -120,8 +120,7 @@ void Texture::initialize(const SwapchainTextureInfo &info, Texture *out) {
out->doInit(info);
}
-void Texture::updateTextureInfo(const SwapchainTextureInfo &info, Texture *out)
-{
+void Texture::updateTextureInfo(const SwapchainTextureInfo &info, Texture *out) {
out->_info.type = TextureType::TEX2D;
out->_info.format = info.format;
out->_info.width = info.width;
diff --git a/native/cocos/renderer/gfx-gles2/GLES2Std.h b/native/cocos/renderer/gfx-gles2/GLES2Std.h
index 2f52ff50dd..f8efadba91 100644
--- a/native/cocos/renderer/gfx-gles2/GLES2Std.h
+++ b/native/cocos/renderer/gfx-gles2/GLES2Std.h
@@ -47,7 +47,7 @@
GLenum err = glGetError(); \
if (err != GL_NO_ERROR) { \
CC_LOG_ERROR("%s returned GL error: 0x%x", #x, err); \
- CC_ABORT(); \
+ CC_ABORT(); \
} \
} while (0)
#define EGL_CHECK(x) \
@@ -56,7 +56,7 @@
EGLint err = eglGetError(); \
if (err != EGL_SUCCESS) { \
CC_LOG_ERROR("%s returned EGL error: 0x%x", #x, err); \
- CC_ABORT(); \
+ CC_ABORT(); \
} \
} while (0)
#else
diff --git a/native/cocos/renderer/gfx-gles3/GLES3Std.h b/native/cocos/renderer/gfx-gles3/GLES3Std.h
index 67c56368be..36d05df39a 100644
--- a/native/cocos/renderer/gfx-gles3/GLES3Std.h
+++ b/native/cocos/renderer/gfx-gles3/GLES3Std.h
@@ -47,7 +47,7 @@
GLenum err = glGetError(); \
if (err != GL_NO_ERROR) { \
CC_LOG_ERROR("%s returned GL error: 0x%x", #x, err); \
- CC_ABORT(); \
+ CC_ABORT(); \
} \
} while (0)
#define EGL_CHECK(x) \
@@ -56,7 +56,7 @@
EGLint err = eglGetError(); \
if (err != EGL_SUCCESS) { \
CC_LOG_ERROR("%s returned EGL error: 0x%x", #x, err); \
- CC_ABORT(); \
+ CC_ABORT(); \
} \
} while (0)
#else
diff --git a/native/cocos/renderer/gfx-gles3/GLES3Swapchain.cpp b/native/cocos/renderer/gfx-gles3/GLES3Swapchain.cpp
index 6733aff46d..a2e679c2d5 100644
--- a/native/cocos/renderer/gfx-gles3/GLES3Swapchain.cpp
+++ b/native/cocos/renderer/gfx-gles3/GLES3Swapchain.cpp
@@ -25,9 +25,9 @@
#include "application/ApplicationManager.h"
#include "platform/interfaces/modules/IXRInterface.h"
-#include "GLES3Swapchain.h"
#include "GLES3Device.h"
#include "GLES3GPUObjects.h"
+#include "GLES3Swapchain.h"
#include "GLES3Texture.h"
#if CC_SWAPPY_ENABLED
diff --git a/native/cocos/renderer/gfx-gles3/GLES3Wrangler.cpp b/native/cocos/renderer/gfx-gles3/GLES3Wrangler.cpp
index ac8bb5d83e..04c298444f 100644
--- a/native/cocos/renderer/gfx-gles3/GLES3Wrangler.cpp
+++ b/native/cocos/renderer/gfx-gles3/GLES3Wrangler.cpp
@@ -49,14 +49,14 @@ bool gles3wOpen() {
int times = 1;
do {
auto size = MAX_PATH * times++;
- char *path = static_cast(CC_MALLOC(size));
+ char *path = static_cast(CC_MALLOC(size));
if (path) {
GetModuleFileNameA(engine, path, size);
dir = path;
}
CC_FREE(path);
} while (GetLastError() == ERROR_INSUFFICIENT_BUFFER);
-
+
dir = dir.substr(0, dir.rfind("\\") + 1);
eglPath = dir + eglPath;
glesPath = dir + glesPath;
diff --git a/native/cocos/renderer/gfx-validator/BufferValidator.cpp b/native/cocos/renderer/gfx-validator/BufferValidator.cpp
index 413600fd3f..a6e5f691b0 100644
--- a/native/cocos/renderer/gfx-validator/BufferValidator.cpp
+++ b/native/cocos/renderer/gfx-validator/BufferValidator.cpp
@@ -204,6 +204,5 @@ uint8_t *BufferValidator::getStagingAddress() const {
return Buffer::getBufferStagingAddress(_actor);
}
-
} // namespace gfx
} // namespace cc
diff --git a/native/cocos/renderer/gfx-validator/TextureValidator.cpp b/native/cocos/renderer/gfx-validator/TextureValidator.cpp
index bb92c25480..c0bc45a239 100644
--- a/native/cocos/renderer/gfx-validator/TextureValidator.cpp
+++ b/native/cocos/renderer/gfx-validator/TextureValidator.cpp
@@ -74,15 +74,13 @@ void TextureValidator::doInit(const TextureInfo &info) {
break;
}
case TextureType::TEX1D_ARRAY: {
- if (std::min(info.width, info.height) > 1 || std::max(info.width, info.height) > DeviceValidator::getInstance()->getCapabilities().maxTextureSize
- || info.layerCount > DeviceValidator::getInstance()->getCapabilities().maxArrayTextureLayers) {
+ if (std::min(info.width, info.height) > 1 || std::max(info.width, info.height) > DeviceValidator::getInstance()->getCapabilities().maxTextureSize || info.layerCount > DeviceValidator::getInstance()->getCapabilities().maxArrayTextureLayers) {
CC_ABORT();
}
break;
}
case TextureType::TEX2D_ARRAY: {
- if (std::max(info.width, info.height) > DeviceValidator::getInstance()->getCapabilities().maxTextureSize
- || info.layerCount > DeviceValidator::getInstance()->getCapabilities().maxArrayTextureLayers) {
+ if (std::max(info.width, info.height) > DeviceValidator::getInstance()->getCapabilities().maxTextureSize || info.layerCount > DeviceValidator::getInstance()->getCapabilities().maxArrayTextureLayers) {
CC_ABORT();
}
break;
diff --git a/native/cocos/renderer/gfx-vulkan/VKDescriptorSetLayout.h b/native/cocos/renderer/gfx-vulkan/VKDescriptorSetLayout.h
index b1533f4c64..5deccd3373 100644
--- a/native/cocos/renderer/gfx-vulkan/VKDescriptorSetLayout.h
+++ b/native/cocos/renderer/gfx-vulkan/VKDescriptorSetLayout.h
@@ -31,7 +31,6 @@
namespace cc {
namespace gfx {
-
class CC_VULKAN_API CCVKDescriptorSetLayout final : public DescriptorSetLayout {
public:
CCVKDescriptorSetLayout();
diff --git a/native/cocos/renderer/gfx-vulkan/VKGPUObjects.h b/native/cocos/renderer/gfx-vulkan/VKGPUObjects.h
index da50c3a91a..13f604c367 100644
--- a/native/cocos/renderer/gfx-vulkan/VKGPUObjects.h
+++ b/native/cocos/renderer/gfx-vulkan/VKGPUObjects.h
@@ -238,7 +238,7 @@ struct CCVKGPUBufferView : public CCVKGPUDeviceObject {
uint32_t offset = 0U;
uint32_t range = 0U;
- uint8_t* mappedData() const {
+ uint8_t *mappedData() const {
return gpuBuffer->mappedData + offset;
}
@@ -1069,11 +1069,11 @@ public:
void collect(uint32_t layoutId, VkDescriptorSet set);
void collect(const CCVKGPUBuffer *buffer);
-#define DEFINE_RECYCLE_BIN_COLLECT_FN(_type, typeValue, expr) \
+#define DEFINE_RECYCLE_BIN_COLLECT_FN(_type, typeValue, expr) \
void collect(const _type *gpuRes) { /* NOLINT(bugprone-macro-parentheses) N/A */ \
- Resource &res = emplaceBack(); \
- res.type = typeValue; \
- expr; \
+ Resource &res = emplaceBack(); \
+ res.type = typeValue; \
+ expr; \
}
DEFINE_RECYCLE_BIN_COLLECT_FN(CCVKGPURenderPass, RecycledType::RENDER_PASS, res.vkRenderPass = gpuRes->vkRenderPass)
@@ -1153,7 +1153,7 @@ public:
_ias[buffer].insert(ia);
}
- void update(CCVKGPUBufferView* oldBuffer, CCVKGPUBufferView* newBuffer) {
+ void update(CCVKGPUBufferView *oldBuffer, CCVKGPUBufferView *newBuffer) {
auto iter = _ias.find(oldBuffer);
if (iter != _ias.end()) {
for (const auto &ia : iter->second) {
diff --git a/native/cocos/renderer/gfx-vulkan/VKGPURecycleBin.cpp b/native/cocos/renderer/gfx-vulkan/VKGPURecycleBin.cpp
index c48f7aa87e..c542bada85 100644
--- a/native/cocos/renderer/gfx-vulkan/VKGPURecycleBin.cpp
+++ b/native/cocos/renderer/gfx-vulkan/VKGPURecycleBin.cpp
@@ -20,13 +20,12 @@ Permission is hereby granted, free of charge, to any person obtaining a copy
THE SOFTWARE.
****************************************************************************/
-#include "VKGPUObjects.h"
#include "VKDevice.h"
+#include "VKGPUObjects.h"
namespace cc {
namespace gfx {
void CCVKGPURecycleBin::collect(const cc::gfx::CCVKGPUTexture *texture) {
-
auto collectHandleFn = [this](VkImage image, VmaAllocation allocation) {
Resource &res = emplaceBack();
res.type = RecycledType::TEXTURE;
@@ -49,7 +48,7 @@ void CCVKGPURecycleBin::collect(const cc::gfx::CCVKGPUTextureView *textureView)
res.vkImageView = view;
};
collectHandleFn(textureView->vkImageView);
- for (const auto& swapChainView : textureView->swapchainVkImageViews) {
+ for (const auto &swapChainView : textureView->swapchainVkImageViews) {
collectHandleFn(swapChainView);
}
}
@@ -61,13 +60,13 @@ void CCVKGPURecycleBin::collect(const CCVKGPUFramebuffer *frameBuffer) {
res.vkFramebuffer = fbo;
};
collectHandleFn(frameBuffer->vkFramebuffer);
- for (const auto& fbo : frameBuffer->vkFrameBuffers) {
+ for (const auto &fbo : frameBuffer->vkFrameBuffers) {
collectHandleFn(fbo);
}
}
void CCVKGPURecycleBin::collect(const CCVKGPUDescriptorSet *set) {
- for (const auto& instance : set->instances) {
+ for (const auto &instance : set->instances) {
collect(set->layoutID, instance.vkDescriptorSet);
}
}
diff --git a/native/cocos/renderer/gfx-vulkan/VKInputAssembler.cpp b/native/cocos/renderer/gfx-vulkan/VKInputAssembler.cpp
index 96829b29f3..f7dae717a6 100644
--- a/native/cocos/renderer/gfx-vulkan/VKInputAssembler.cpp
+++ b/native/cocos/renderer/gfx-vulkan/VKInputAssembler.cpp
@@ -78,7 +78,7 @@ void CCVKInputAssembler::doDestroy() {
void CCVKGPUInputAssembler::shutdown() {
auto *hub = CCVKDevice::getInstance()->gpuIAHub();
- for (auto& vb : gpuVertexBuffers) {
+ for (auto &vb : gpuVertexBuffers) {
hub->disengage(this, vb);
}
if (gpuIndexBuffer) {
diff --git a/native/cocos/renderer/gfx-vulkan/VKShader.cpp b/native/cocos/renderer/gfx-vulkan/VKShader.cpp
index 6d414a1fb4..9e23a2a185 100644
--- a/native/cocos/renderer/gfx-vulkan/VKShader.cpp
+++ b/native/cocos/renderer/gfx-vulkan/VKShader.cpp
@@ -76,7 +76,7 @@ void CCVKShader::doInit(const ShaderInfo & /*info*/) {
}
void CCVKShader::doDestroy() {
- _gpuShader = nullptr;
+ _gpuShader = nullptr;
}
void CCVKGPUShader::shutdown() {
diff --git a/native/cocos/renderer/gfx-vulkan/VKStd.h b/native/cocos/renderer/gfx-vulkan/VKStd.h
index 08aec37cb4..6384018e00 100644
--- a/native/cocos/renderer/gfx-vulkan/VKStd.h
+++ b/native/cocos/renderer/gfx-vulkan/VKStd.h
@@ -46,7 +46,7 @@
VkResult err = x; \
if (err) { \
CC_LOG_ERROR("%s returned Vulkan error: %d", #x, err); \
- CC_ABORT(); \
+ CC_ABORT(); \
} \
} while (0)
diff --git a/native/cocos/renderer/pipeline/PipelineSceneData.cpp b/native/cocos/renderer/pipeline/PipelineSceneData.cpp
index c5461e429e..09e4db7525 100644
--- a/native/cocos/renderer/pipeline/PipelineSceneData.cpp
+++ b/native/cocos/renderer/pipeline/PipelineSceneData.cpp
@@ -29,13 +29,13 @@
#include "gfx-base/GFXDef-common.h"
#include "gfx-base/GFXDevice.h"
#include "gfx-base/GFXFramebuffer.h"
+#include "gi/light-probe/LightProbe.h"
#include "scene/Ambient.h"
#include "scene/Fog.h"
#include "scene/Octree.h"
#include "scene/Pass.h"
#include "scene/Shadow.h"
#include "scene/Skybox.h"
-#include "gi/light-probe/LightProbe.h"
namespace cc {
namespace pipeline {
diff --git a/native/cocos/renderer/pipeline/ReflectionProbeBatchedQueue.cpp b/native/cocos/renderer/pipeline/ReflectionProbeBatchedQueue.cpp
index 5a724be307..930986f71b 100644
--- a/native/cocos/renderer/pipeline/ReflectionProbeBatchedQueue.cpp
+++ b/native/cocos/renderer/pipeline/ReflectionProbeBatchedQueue.cpp
@@ -31,26 +31,21 @@
#include "RenderBatchedQueue.h"
#include "RenderInstancedQueue.h"
#include "core/geometry/AABB.h"
+#include "core/geometry/Intersect.h"
#include "forward/ForwardPipeline.h"
#include "gfx-base/GFXCommandBuffer.h"
#include "gfx-base/GFXDevice.h"
#include "renderer/core/ProgramLib.h"
-#include "scene/ReflectionProbeManager.h"
#include "scene/Camera.h"
-#include "scene/ReflectionProbe.h"
-#include "scene/Skybox.h"
#include "scene/Define.h"
-#include "core/geometry/Intersect.h"
+#include "scene/ReflectionProbe.h"
+#include "scene/ReflectionProbeManager.h"
+#include "scene/Skybox.h"
namespace cc {
namespace pipeline {
-const static uint32_t REFLECTION_PROBE_DEFAULT_MASK = ~static_cast(LayerList::UI_2D)
- & ~static_cast(LayerList::PROFILER)
- & ~static_cast(LayerList::UI_3D)
- & ~static_cast(LayerList::GIZMOS)
- & ~static_cast(LayerList::SCENE_GIZMO)
- & ~static_cast(LayerList::EDITOR);
+const static uint32_t REFLECTION_PROBE_DEFAULT_MASK = ~static_cast(LayerList::UI_2D) & ~static_cast(LayerList::PROFILER) & ~static_cast(LayerList::UI_3D) & ~static_cast(LayerList::GIZMOS) & ~static_cast(LayerList::SCENE_GIZMO) & ~static_cast(LayerList::EDITOR);
const ccstd::string CC_USE_RGBE_OUTPUT = "CC_USE_RGBE_OUTPUT";
-const cc::scene::IMacroPatch MACRO_PATCH_RGBE_OUTPUT{ CC_USE_RGBE_OUTPUT, true};
+const cc::scene::IMacroPatch MACRO_PATCH_RGBE_OUTPUT{CC_USE_RGBE_OUTPUT, true};
ReflectionProbeBatchedQueue::ReflectionProbeBatchedQueue(RenderPipeline *pipeline)
: _phaseID(getPhaseID("default")), _phaseReflectMapID(getPhaseID("reflect-map")) {
_pipeline = pipeline;
@@ -131,7 +126,7 @@ void ReflectionProbeBatchedQueue::add(const scene::Model *model) {
auto *pass = subModel->getPass(passIdx);
const auto batchingScheme = pass->getBatchingScheme();
- if (!bUseReflectPass) {
+ if (!bUseReflectPass) {
auto patches = const_cast &>(subModel->getPatches());
patches.emplace_back(MACRO_PATCH_RGBE_OUTPUT);
subModel->onMacroPatchesStateChanged(patches);
@@ -181,7 +176,7 @@ void ReflectionProbeBatchedQueue::resetMacro() const {
for (auto iter = patches.begin(); iter != patches.end(); iter++) {
if (iter->name == CC_USE_RGBE_OUTPUT) {
patches.erase(iter);
- const_cast(subModel)->onMacroPatchesStateChanged(patches);
+ const_cast(subModel)->onMacroPatchesStateChanged(patches);
break;
}
}
diff --git a/native/cocos/renderer/pipeline/ReflectionProbeBatchedQueue.h b/native/cocos/renderer/pipeline/ReflectionProbeBatchedQueue.h
index 399992d6c4..08dac4ff3a 100644
--- a/native/cocos/renderer/pipeline/ReflectionProbeBatchedQueue.h
+++ b/native/cocos/renderer/pipeline/ReflectionProbeBatchedQueue.h
@@ -51,7 +51,7 @@ public:
void add(const scene::Model *);
void recordCommandBuffer(gfx::Device *, gfx::RenderPass *, gfx::CommandBuffer *) const;
- void resetMacro()const;
+ void resetMacro() const;
bool isUseReflectMapPass(const scene::SubModel *subModel) const;
diff --git a/native/cocos/renderer/pipeline/RenderPipeline.h b/native/cocos/renderer/pipeline/RenderPipeline.h
index 707b0ec3b8..c8abdf8d03 100644
--- a/native/cocos/renderer/pipeline/RenderPipeline.h
+++ b/native/cocos/renderer/pipeline/RenderPipeline.h
@@ -204,7 +204,6 @@ protected:
bool _resetRenderQueue{true};
render::PipelineRuntime *_pipelineRuntime{nullptr};
-
};
} // namespace pipeline
diff --git a/native/cocos/renderer/pipeline/RenderStage.h b/native/cocos/renderer/pipeline/RenderStage.h
index 2af0d0374c..6aea7ae78c 100644
--- a/native/cocos/renderer/pipeline/RenderStage.h
+++ b/native/cocos/renderer/pipeline/RenderStage.h
@@ -57,9 +57,9 @@ public:
virtual bool initialize(const RenderStageInfo &info);
virtual void destroy();
-
+
// should not be pure virtual, since it will be instantiated in inspector
- virtual void render(scene::Camera *camera) {}
+ virtual void render(scene::Camera *camera) {}
inline const ccstd::string &getName() const { return _name; }
inline void setName(ccstd::string &name) { _name = name; }
diff --git a/native/cocos/renderer/pipeline/ShadowMapBatchedQueue.cpp b/native/cocos/renderer/pipeline/ShadowMapBatchedQueue.cpp
index 64634d68a2..cc414e985a 100644
--- a/native/cocos/renderer/pipeline/ShadowMapBatchedQueue.cpp
+++ b/native/cocos/renderer/pipeline/ShadowMapBatchedQueue.cpp
@@ -86,8 +86,7 @@ void ShadowMapBatchedQueue::gatherLightPasses(const scene::Camera *camera, const
geometry::AABB ab;
for (const auto &ro : castShadowObjects) {
const auto *model = ro.model;
- if ((visibility & model->getNode()->getLayer()) != model->getNode()->getLayer()
- || !model->isEnabled() || !model->isCastShadow() || !model->getNode()) {
+ if ((visibility & model->getNode()->getLayer()) != model->getNode()->getLayer() || !model->isEnabled() || !model->isCastShadow() || !model->getNode()) {
continue;
}
if (model->getWorldBounds()) {
diff --git a/native/cocos/renderer/pipeline/custom/LayoutGraphSerialization.h b/native/cocos/renderer/pipeline/custom/LayoutGraphSerialization.h
index 2112516a75..c7d2884456 100644
--- a/native/cocos/renderer/pipeline/custom/LayoutGraphSerialization.h
+++ b/native/cocos/renderer/pipeline/custom/LayoutGraphSerialization.h
@@ -117,21 +117,21 @@ inline void load(InputArchive& ar, LayoutGraph& g) {
load(ar, u);
load(ar, name);
load(ar, descriptors);
- switch(id) {
- case 0: {
- uint32_t val;
- load(ar, val);
- addVertex(std::move(name), std::move(descriptors), val, g, u);
- break;
- }
- case 1: {
- RenderPhase val(g.get_allocator());
- load(ar, val);
- addVertex(std::move(name), std::move(descriptors), std::move(val), g, u);
- break;
- }
- default:
- throw std::runtime_error("load graph failed");
+ switch (id) {
+ case 0: {
+ uint32_t val;
+ load(ar, val);
+ addVertex(std::move(name), std::move(descriptors), val, g, u);
+ break;
+ }
+ case 1: {
+ RenderPhase val(g.get_allocator());
+ load(ar, val);
+ addVertex(std::move(name), std::move(descriptors), std::move(val), g, u);
+ break;
+ }
+ default:
+ throw std::runtime_error("load graph failed");
}
}
}
@@ -372,21 +372,21 @@ inline void load(InputArchive& ar, LayoutGraphData& g) {
load(ar, name);
load(ar, update);
load(ar, layout);
- switch(id) {
- case 0: {
- RenderStageData val(g.get_allocator());
- load(ar, val);
- addVertex(std::move(name), update, std::move(layout), std::move(val), g, u);
- break;
- }
- case 1: {
- RenderPhaseData val(g.get_allocator());
- load(ar, val);
- addVertex(std::move(name), update, std::move(layout), std::move(val), g, u);
- break;
- }
- default:
- throw std::runtime_error("load graph failed");
+ switch (id) {
+ case 0: {
+ RenderStageData val(g.get_allocator());
+ load(ar, val);
+ addVertex(std::move(name), update, std::move(layout), std::move(val), g, u);
+ break;
+ }
+ case 1: {
+ RenderPhaseData val(g.get_allocator());
+ load(ar, val);
+ addVertex(std::move(name), update, std::move(layout), std::move(val), g, u);
+ break;
+ }
+ default:
+ throw std::runtime_error("load graph failed");
}
}
load(ar, g.valueNames);
diff --git a/native/cocos/renderer/pipeline/custom/NativeDefaultScene.cpp b/native/cocos/renderer/pipeline/custom/NativeDefaultScene.cpp
index 77fbc779f1..219ef6690e 100644
--- a/native/cocos/renderer/pipeline/custom/NativeDefaultScene.cpp
+++ b/native/cocos/renderer/pipeline/custom/NativeDefaultScene.cpp
@@ -40,7 +40,7 @@ void DefaultSceneVisitor::bindInputAssembler(gfx::InputAssembler *ia) {}
void DefaultSceneVisitor::updateBuffer(gfx::Buffer *buff, const void *data, uint32_t size) {}
void DefaultSceneVisitor::draw(const gfx::DrawInfo &info) {}
-SceneTask* DefaultForwardLightingTransversal::transverse(SceneVisitor *visitor) const {
+SceneTask *DefaultForwardLightingTransversal::transverse(SceneVisitor *visitor) const {
std::ignore = visitor;
return nullptr;
}
diff --git a/native/cocos/renderer/pipeline/forward/ForwardFlow.cpp b/native/cocos/renderer/pipeline/forward/ForwardFlow.cpp
index 179f3d337a..84f6f56243 100644
--- a/native/cocos/renderer/pipeline/forward/ForwardFlow.cpp
+++ b/native/cocos/renderer/pipeline/forward/ForwardFlow.cpp
@@ -29,7 +29,7 @@
#include "profiler/Profiler.h"
#if CC_USE_AR_MODULE
-#include "pipeline/xr/ar/ARStage.h"
+ #include "pipeline/xr/ar/ARStage.h"
#endif
namespace cc {
@@ -50,11 +50,11 @@ bool ForwardFlow::initialize(const RenderFlowInfo &info) {
if (_stages.empty()) {
_isResourceOwner = true;
- #if CC_USE_AR_MODULE
- auto *arStage = ccnew ARStage;
- arStage->initialize(ARStage::getInitializeInfo());
- _stages.emplace_back(arStage);
- #endif
+#if CC_USE_AR_MODULE
+ auto *arStage = ccnew ARStage;
+ arStage->initialize(ARStage::getInitializeInfo());
+ _stages.emplace_back(arStage);
+#endif
auto *forwardStage = ccnew ForwardStage;
forwardStage->initialize(ForwardStage::getInitializeInfo());
_stages.emplace_back(forwardStage);
diff --git a/native/cocos/renderer/pipeline/forward/ForwardPipeline.cpp b/native/cocos/renderer/pipeline/forward/ForwardPipeline.cpp
index a4e0146124..9257e4b26b 100644
--- a/native/cocos/renderer/pipeline/forward/ForwardPipeline.cpp
+++ b/native/cocos/renderer/pipeline/forward/ForwardPipeline.cpp
@@ -28,13 +28,13 @@
#include "../PipelineUBO.h"
#include "../SceneCulling.h"
#include "../helper/Utils.h"
+#include "../reflection-probe/ReflectionProbeFlow.h"
#include "../shadow/ShadowFlow.h"
#include "ForwardFlow.h"
#include "gfx-base/GFXDevice.h"
#include "profiler/Profiler.h"
#include "scene/Camera.h"
#include "scene/RenderScene.h"
-#include "../reflection-probe/ReflectionProbeFlow.h"
namespace cc {
namespace pipeline {
diff --git a/native/cocos/renderer/pipeline/forward/ForwardStage.cpp b/native/cocos/renderer/pipeline/forward/ForwardStage.cpp
index dfa4ef8471..1a5a47ecda 100644
--- a/native/cocos/renderer/pipeline/forward/ForwardStage.cpp
+++ b/native/cocos/renderer/pipeline/forward/ForwardStage.cpp
@@ -179,7 +179,7 @@ void ForwardStage::render(scene::Camera *camera) {
auto clearFlags = static_cast(camera->getClearFlag());
data.outputTex = framegraph::TextureHandle(builder.readFromBlackboard(RenderPipeline::fgStrHandleOutColorTexture));
- if(!data.outputTex.isValid()) {
+ if (!data.outputTex.isValid()) {
framegraph::Texture::Descriptor colorTexInfo;
colorTexInfo.format = sceneData->isHDR() ? gfx::Format::RGBA16F : gfx::Format::RGBA8;
colorTexInfo.usage = gfx::TextureUsageBit::COLOR_ATTACHMENT;
diff --git a/native/cocos/renderer/pipeline/helper/Utils.cpp b/native/cocos/renderer/pipeline/helper/Utils.cpp
index 4a2fd94a5d..3c224906b3 100644
--- a/native/cocos/renderer/pipeline/helper/Utils.cpp
+++ b/native/cocos/renderer/pipeline/helper/Utils.cpp
@@ -57,7 +57,7 @@ void renderProfiler(gfx::RenderPass *renderPass, gfx::CommandBuffer *cmdBuff, sc
#if CC_EDITOR
if (!(camera->getVisibility() & static_cast(pipeline::LayerList::PROFILER))) {
- return;
+ return;
}
#else
if (camera != profilerCamera) {
diff --git a/native/cocos/renderer/pipeline/reflection-probe/ReflectionProbeFlow.cpp b/native/cocos/renderer/pipeline/reflection-probe/ReflectionProbeFlow.cpp
index 4e39a5179c..d27fe14909 100644
--- a/native/cocos/renderer/pipeline/reflection-probe/ReflectionProbeFlow.cpp
+++ b/native/cocos/renderer/pipeline/reflection-probe/ReflectionProbeFlow.cpp
@@ -26,11 +26,11 @@
#include "ReflectionProbeStage.h"
#include "pipeline/PipelineSceneData.h"
-#include "scene/ReflectionProbeManager.h"
#include "pipeline/RenderPipeline.h"
#include "profiler/Profiler.h"
#include "scene/Camera.h"
#include "scene/ReflectionProbe.h"
+#include "scene/ReflectionProbeManager.h"
namespace cc {
namespace pipeline {
RenderFlowInfo ReflectionProbeFlow::initInfo = {
@@ -62,7 +62,7 @@ void ReflectionProbeFlow::render(scene::Camera *camera) {
CC_PROFILE(ReflectionProbeFlowRender);
const auto *sceneData = _pipeline->getPipelineSceneData();
const auto probes = scene::ReflectionProbeManager::getInstance()->getAllProbes();
- for (auto * probe : probes) {
+ for (auto *probe : probes) {
if (probe->needRender()) {
renderStage(camera, probe);
}
@@ -72,7 +72,7 @@ void ReflectionProbeFlow::render(scene::Camera *camera) {
void ReflectionProbeFlow::renderStage(scene::Camera *camera, scene::ReflectionProbe *probe) {
for (auto &stage : _stages) {
if (probe->getProbeType() == scene::ReflectionProbe::ProbeType::PLANAR) {
- auto * framebuffer = probe->getRealtimePlanarTexture()->getWindow()->getFramebuffer();
+ auto *framebuffer = probe->getRealtimePlanarTexture()->getWindow()->getFramebuffer();
auto *reflectionProbeStage = static_cast(stage.get());
reflectionProbeStage->setUsage(framebuffer, probe);
reflectionProbeStage->render(camera);
@@ -82,15 +82,13 @@ void ReflectionProbeFlow::renderStage(scene::Camera *camera, scene::ReflectionPr
for (uint32_t faceIdx = 0; faceIdx < 6; faceIdx++) {
//update camera dirction
probe->updateCameraDir(faceIdx);
- RenderTexture* rt = probe->getBakedCubeTextures()[faceIdx];
+ RenderTexture *rt = probe->getBakedCubeTextures()[faceIdx];
auto *reflectionProbeStage = static_cast(stage.get());
reflectionProbeStage->setUsage(rt->getWindow()->getFramebuffer(), probe);
reflectionProbeStage->render(camera);
}
probe->setNeedRender(false);
-
}
-
}
}
diff --git a/native/cocos/renderer/pipeline/reflection-probe/ReflectionProbeStage.cpp b/native/cocos/renderer/pipeline/reflection-probe/ReflectionProbeStage.cpp
index ac023dcb0c..54af9f38a5 100644
--- a/native/cocos/renderer/pipeline/reflection-probe/ReflectionProbeStage.cpp
+++ b/native/cocos/renderer/pipeline/reflection-probe/ReflectionProbeStage.cpp
@@ -27,10 +27,10 @@
#include "../PipelineUBO.h"
#include "../ReflectionProbeBatchedQueue.h"
#include "../RenderPipeline.h"
-#include "scene/ReflectionProbeManager.h"
#include "profiler/Profiler.h"
#include "scene/Camera.h"
#include "scene/ReflectionProbe.h"
+#include "scene/ReflectionProbeManager.h"
namespace cc {
namespace pipeline {
@@ -75,7 +75,7 @@ void ReflectionProbeStage::render(scene::Camera *camera) {
if (hasFlag(static_cast(_probe->getCamera()->getClearFlag()), gfx::ClearFlagBit::COLOR)) {
_clearColors[0] = _probe->getCamera()->getClearColor();
}
-
+
auto *renderPass = _framebuffer->getRenderPass();
cmdBuffer->beginRenderPass(renderPass, _framebuffer, _renderArea,
diff --git a/native/cocos/renderer/pipeline/shadow/CSMLayers.h b/native/cocos/renderer/pipeline/shadow/CSMLayers.h
index 693f0a5127..065dd1b4e5 100644
--- a/native/cocos/renderer/pipeline/shadow/CSMLayers.h
+++ b/native/cocos/renderer/pipeline/shadow/CSMLayers.h
@@ -152,7 +152,7 @@ private:
// The ShadowTransformInfo object for 'fixed area shadow' || 'maximum clipping info' || 'CSM layers = 1'.
ShadowTransformInfo *_specialLayer{nullptr};
-
+
float _shadowDistance{0.0F};
ccstd::array _layers{};
diff --git a/native/cocos/renderer/pipeline/shadow/ShadowStage.cpp b/native/cocos/renderer/pipeline/shadow/ShadowStage.cpp
index 51bd90d42f..440050f51d 100644
--- a/native/cocos/renderer/pipeline/shadow/ShadowStage.cpp
+++ b/native/cocos/renderer/pipeline/shadow/ShadowStage.cpp
@@ -53,7 +53,7 @@ const RenderStageInfo &ShadowStage::getInitializeInfo() { return ShadowStage::in
bool ShadowStage::initialize(const RenderStageInfo &info) {
RenderStage::initialize(info);
- auto* descriptor = ccnew RenderQueueDesc(true, RenderQueueSortMode::BACK_TO_FRONT, {"default"});
+ auto *descriptor = ccnew RenderQueueDesc(true, RenderQueueSortMode::BACK_TO_FRONT, {"default"});
_renderQueueDescriptors.emplace_back(descriptor);
return true;
diff --git a/native/cocos/renderer/pipeline/xr/ar/ARBackground.h b/native/cocos/renderer/pipeline/xr/ar/ARBackground.h
index 3f1792b711..3a4b94c963 100644
--- a/native/cocos/renderer/pipeline/xr/ar/ARBackground.h
+++ b/native/cocos/renderer/pipeline/xr/ar/ARBackground.h
@@ -72,7 +72,7 @@ private:
gfx::DescriptorSet* _descriptorSet{nullptr};
gfx::PipelineLayout* _pipelineLayout{nullptr};
gfx::PipelineState* _pipelineState{nullptr};
-
+
#if CC_PLATFORM == CC_PLATFORM_ANDROID
gfx::Buffer* _uniformBuffer{nullptr};
GLuint _glTex{0U};
diff --git a/native/cocos/renderer/pipeline/xr/ar/ARStage.cpp b/native/cocos/renderer/pipeline/xr/ar/ARStage.cpp
index 10d512dba9..0ccde60007 100644
--- a/native/cocos/renderer/pipeline/xr/ar/ARStage.cpp
+++ b/native/cocos/renderer/pipeline/xr/ar/ARStage.cpp
@@ -24,17 +24,17 @@
#include "pipeline/xr/ar/ARStage.h"
#include "ar/ARModule.h"
-#include "pipeline/xr/ar/ARBackground.h"
-#include "pipeline/Enum.h"
-#include "pipeline/PipelineSceneData.h"
-#include "pipeline/PipelineUBO.h"
-#include "pipeline/forward/ForwardPipeline.h"
#include "core/scene-graph/Node.h"
#include "gfx-base/GFXCommandBuffer.h"
#include "gfx-base/GFXDef-common.h"
#include "gfx-base/GFXFramebuffer.h"
#include "gfx-base/GFXTexture.h"
+#include "pipeline/Enum.h"
+#include "pipeline/PipelineSceneData.h"
+#include "pipeline/PipelineUBO.h"
#include "pipeline/RenderPipeline.h"
+#include "pipeline/forward/ForwardPipeline.h"
+#include "pipeline/xr/ar/ARBackground.h"
#include "scene/Camera.h"
#include "scene/RenderWindow.h"
@@ -122,7 +122,7 @@ void ARStage::render(scene::Camera *camera) {
data.depth = builder.create(RenderPipeline::fgStrHandleOutDepthTexture, depthTexInfo);
data.depth = builder.write(data.depth, depthAttachmentInfo);
-
+
builder.writeToBlackboard(RenderPipeline::fgStrHandleOutColorTexture, data.outputTex);
builder.writeToBlackboard(RenderPipeline::fgStrHandleOutDepthTexture, data.depth);
builder.setViewport(_pipeline->getViewport(camera), _pipeline->getScissor(camera));
diff --git a/native/cocos/scene/Camera.cpp b/native/cocos/scene/Camera.cpp
index c966eabd0a..d156894109 100644
--- a/native/cocos/scene/Camera.cpp
+++ b/native/cocos/scene/Camera.cpp
@@ -156,7 +156,6 @@ void Camera::syncCameraEditor(const Camera *camera) {
_matProjInv = camera->_matProjInv;
_matViewProj = camera->_matViewProj;
#endif
-
}
void Camera::update(bool forceUpdate /*false*/) {
@@ -396,7 +395,7 @@ Mat4 Camera::worldMatrixToScreen(const Mat4 &worldMatrix, uint32_t width, uint32
* @zh 计算并设置斜视锥体投影矩阵
* @param clipPlane clip plane in camera space
*/
-void Camera::calculateObliqueMat(const Vec4& viewSpacePlane) {
+void Camera::calculateObliqueMat(const Vec4 &viewSpacePlane) {
float clipSpaceMinZ = _device->getCapabilities().clipSpaceMinZ;
Vec4 far{math::sgn(viewSpacePlane.x), math::sgn(viewSpacePlane.y), 1.F, 0.F};
diff --git a/native/cocos/scene/Camera.h b/native/cocos/scene/Camera.h
index c0db045387..36439e3158 100644
--- a/native/cocos/scene/Camera.h
+++ b/native/cocos/scene/Camera.h
@@ -364,7 +364,8 @@ public:
inline bool isCullingEnabled() const { return _isCullingEnabled; }
inline void setCullingEnable(bool val) { _isCullingEnabled = val; }
- void calculateObliqueMat(const Vec4& viewSpacePlane);
+ void calculateObliqueMat(const Vec4 &viewSpacePlane);
+
protected:
void setExposure(float ev100);
diff --git a/native/cocos/scene/LODGroup.cpp b/native/cocos/scene/LODGroup.cpp
index 64192ab939..ebf336a7b4 100644
--- a/native/cocos/scene/LODGroup.cpp
+++ b/native/cocos/scene/LODGroup.cpp
@@ -41,7 +41,6 @@ LODGroup::LODGroup() = default;
LODGroup::~LODGroup() = default;
-
int8_t LODGroup::getVisibleLODLevel(const Camera *camera) const {
float screenUsagePercentage = getScreenUsagePercentage(camera);
diff --git a/native/cocos/scene/LODGroup.h b/native/cocos/scene/LODGroup.h
index 7044ed8dda..a96fe42945 100644
--- a/native/cocos/scene/LODGroup.h
+++ b/native/cocos/scene/LODGroup.h
@@ -82,12 +82,11 @@ public:
int8_t getVisibleLODLevel(const Camera *camera) const;
- inline const ccstd::vector& getLockedLODLevels() const { return _vecLockedLevels; }
+ inline const ccstd::vector &getLockedLODLevels() const { return _vecLockedLevels; }
void lockLODLevels(ccstd::vector &levels);
inline bool isLockLevelChanged() const { return _isLockLevelChanged; }
inline void resetLockChangeFlag() { _isLockLevelChanged = false; }
-
inline uint8_t getLodCount() const { return _vecLODData.size(); }
inline void clearLODs() { _vecLODData.clear(); }
void insertLOD(uint8_t index, LODData *data);
diff --git a/native/cocos/scene/Model.h b/native/cocos/scene/Model.h
index bc570b098b..ad2781341c 100644
--- a/native/cocos/scene/Model.h
+++ b/native/cocos/scene/Model.h
@@ -31,6 +31,7 @@
#include "core/TypedArray.h"
#include "core/assets/RenderingSubMesh.h"
#include "core/assets/Texture2D.h"
+#include "core/assets/TextureCube.h"
#include "core/builtin/BuiltinResMgr.h"
#include "core/event/EventTarget.h"
#include "core/geometry/AABB.h"
@@ -40,7 +41,6 @@
#include "renderer/gfx-base/GFXDef-common.h"
#include "renderer/gfx-base/GFXTexture.h"
#include "scene/SubModel.h"
-#include "core/assets/TextureCube.h"
namespace cc {
diff --git a/native/cocos/scene/Pass.cpp b/native/cocos/scene/Pass.cpp
index dcb7f1b068..7ea68c06fe 100644
--- a/native/cocos/scene/Pass.cpp
+++ b/native/cocos/scene/Pass.cpp
@@ -24,6 +24,7 @@
#include "scene/Pass.h"
#include "base/std/hash/hash.h"
+#include "cocos/bindings/jswrapper/SeApi.h"
#include "core/Root.h"
#include "core/assets/TextureBase.h"
#include "core/builtin/BuiltinResMgr.h"
@@ -36,7 +37,6 @@
#include "renderer/pipeline/Define.h"
#include "renderer/pipeline/InstancedBuffer.h"
#include "scene/Define.h"
-#include "cocos/bindings/jswrapper/SeApi.h"
namespace cc {
namespace scene {
@@ -346,7 +346,7 @@ void Pass::resetUniform(const ccstd::string &name) {
const auto &floatArr = ccstd::get>(value);
auto iter = type2writer.find(type);
if (iter != type2writer.end()) {
- CC_ASSERT_EQ(floatArr.size() , 2);
+ CC_ASSERT_EQ(floatArr.size(), 2);
iter->second(block.data, toMaterialProperty(type, floatArr), static_cast(ofs));
}
}
diff --git a/native/cocos/scene/ReflectionProbe.cpp b/native/cocos/scene/ReflectionProbe.cpp
index 5a82e762d3..e66d264eda 100644
--- a/native/cocos/scene/ReflectionProbe.cpp
+++ b/native/cocos/scene/ReflectionProbe.cpp
@@ -144,7 +144,7 @@ void ReflectionProbe::transformReflectionCamera(const Camera* sourceCamera) {
_camera->update(true);
// Transform the plane from world space to reflection camera space use the inverse transpose matrix
- Vec4 viewSpaceProbe{ Vec3::UNIT_Y.x, Vec3::UNIT_Y.y, Vec3::UNIT_Y.z, -Vec3::dot(Vec3::UNIT_Y, _node->getWorldPosition()) };
+ Vec4 viewSpaceProbe{Vec3::UNIT_Y.x, Vec3::UNIT_Y.y, Vec3::UNIT_Y.z, -Vec3::dot(Vec3::UNIT_Y, _node->getWorldPosition())};
Mat4 matView = _camera->getMatView();
matView.inverse();
matView.transpose();
@@ -183,7 +183,7 @@ void ReflectionProbe::updatePlanarTexture(const scene::RenderScene* scene) {
if (!modelWorldBounds) {
continue;
}
- const auto *probeBoundingBox = getBoundingBox();
+ const auto* probeBoundingBox = getBoundingBox();
if (modelWorldBounds->aabbAabb(*probeBoundingBox)) {
model->updateReflctionProbePlanarMap(_realtimePlanarTexture->getGFXTexture());
}
diff --git a/native/cocos/scene/ReflectionProbe.h b/native/cocos/scene/ReflectionProbe.h
index 19e4ffe909..62ded01d78 100644
--- a/native/cocos/scene/ReflectionProbe.h
+++ b/native/cocos/scene/ReflectionProbe.h
@@ -76,7 +76,6 @@ public:
inline void setBackgroundColor(gfx::Color& val) {
_backgroundColor = val;
_camera->setClearColor(val);
-
}
inline const gfx::Color& getBackgroundColor() const { return _backgroundColor; }
@@ -108,7 +107,7 @@ public:
inline const geometry::AABB* getBoundingBox() const { return _boundingBox; }
inline void setCameraNode(Node* val) { _cameraNode = val; }
- inline Node* getCameraNode()const { return _cameraNode; }
+ inline Node* getCameraNode() const { return _cameraNode; }
inline void setPreviewSphere(Node* val) { _previewSphere = val; }
inline const Node* getPreviewSphere() const { return _previewSphere; }
@@ -143,6 +142,7 @@ public:
void updateCameraDir(int32_t faceIdx);
Vec2 getRenderArea() const;
void packBackgroundColor();
+
private:
ccstd::vector> _bakedCubeTextures;
IntrusivePtr _realtimePlanarTexture{nullptr};
diff --git a/native/cocos/scene/RenderScene.cpp b/native/cocos/scene/RenderScene.cpp
index 9467edbf31..78b0399c85 100644
--- a/native/cocos/scene/RenderScene.cpp
+++ b/native/cocos/scene/RenderScene.cpp
@@ -63,7 +63,7 @@ public:
* @zh model 能被看到的相机列表
* @en List of cameras that model can be seen.
*/
- ccstd::unordered_map visibleCameras;
+ ccstd::unordered_map visibleCameras;
};
struct LODInfo {
@@ -75,7 +75,7 @@ public:
bool transformDirty{true};
};
- explicit LodStateCache(RenderScene* scene) : _renderScene(scene) {};
+ explicit LodStateCache(RenderScene *scene) : _renderScene(scene){};
~LodStateCache() override = default;
void addCamera(const Camera *camera);
diff --git a/native/cocos/scene/RenderWindow.cpp b/native/cocos/scene/RenderWindow.cpp
index a92c19c6e1..ca5d445414 100644
--- a/native/cocos/scene/RenderWindow.cpp
+++ b/native/cocos/scene/RenderWindow.cpp
@@ -24,8 +24,8 @@
#include "scene/RenderWindow.h"
#include "BasePlatform.h"
-#include "interfaces/modules/ISystemWindowManager.h"
#include "interfaces/modules/ISystemWindow.h"
+#include "interfaces/modules/ISystemWindowManager.h"
#include "platform/interfaces/modules/Device.h"
#include "renderer/gfx-base/GFXDevice.h"
#include "renderer/gfx-base/GFXFramebuffer.h"
diff --git a/native/cocos/scene/Skybox.cpp b/native/cocos/scene/Skybox.cpp
index 4f1f905b94..f9b899e016 100644
--- a/native/cocos/scene/Skybox.cpp
+++ b/native/cocos/scene/Skybox.cpp
@@ -187,7 +187,7 @@ void SkyboxInfo::setReflectionMap(TextureCube *val) {
}
}
-TextureCube* SkyboxInfo::getReflectionMap() const {
+TextureCube *SkyboxInfo::getReflectionMap() const {
const bool isHDR = Root::getInstance()->getPipeline()->getPipelineSceneData()->isHDR();
if (isHDR) {
return _reflectionHDR;
diff --git a/native/cocos/scene/Skybox.h b/native/cocos/scene/Skybox.h
index 3fada151d5..9c550305bd 100644
--- a/native/cocos/scene/Skybox.h
+++ b/native/cocos/scene/Skybox.h
@@ -166,7 +166,7 @@ public:
TextureCube *getDiffuseMap() const;
void setReflectionMap(TextureCube *val);
- TextureCube* getReflectionMap() const;
+ TextureCube *getReflectionMap() const;
void setSkyboxMaterial(Material *val);
inline Material *getSkyboxMaterial() const { return _editableMaterial; }
diff --git a/native/cocos/scene/SubModel.h b/native/cocos/scene/SubModel.h
index db3548d8d5..918f451ab7 100644
--- a/native/cocos/scene/SubModel.h
+++ b/native/cocos/scene/SubModel.h
@@ -125,6 +125,7 @@ protected:
std::shared_ptr>> _passes;
int32_t _reflectionProbeType{0};
+
private:
static inline int32_t generateId() {
static int32_t generator = 0;
diff --git a/native/cocos/ui/edit-box/EditBox-android.cpp b/native/cocos/ui/edit-box/EditBox-android.cpp
index c4b7b6a29c..49406e354b 100644
--- a/native/cocos/ui/edit-box/EditBox-android.cpp
+++ b/native/cocos/ui/edit-box/EditBox-android.cpp
@@ -23,9 +23,9 @@
****************************************************************************/
#include "EditBox.h"
-#include "engine/EngineEvents.h"
#include "cocos/bindings/jswrapper/SeApi.h"
#include "cocos/bindings/manual/jsb_global.h"
+#include "engine/EngineEvents.h"
#include "platform/java/jni/JniHelper.h"
#ifndef JCLS_EDITBOX
diff --git a/native/cocos/ui/edit-box/EditBox-ohos.cpp b/native/cocos/ui/edit-box/EditBox-ohos.cpp
index 33beddbd12..3f6c03009e 100644
--- a/native/cocos/ui/edit-box/EditBox-ohos.cpp
+++ b/native/cocos/ui/edit-box/EditBox-ohos.cpp
@@ -23,9 +23,9 @@
****************************************************************************/
#include "EditBox.h"
-#include "engine/EngineEvents.h"
#include "cocos/bindings/jswrapper/SeApi.h"
#include "cocos/bindings/manual/jsb_global.h"
+#include "engine/EngineEvents.h"
//#include "platform/Application.h"
#include "platform/java/jni/JniHelper.h"
diff --git a/native/cocos/xr/XRRemotePreviewManager.cpp b/native/cocos/xr/XRRemotePreviewManager.cpp
index 9e9db9a59b..24c73b2e47 100644
--- a/native/cocos/xr/XRRemotePreviewManager.cpp
+++ b/native/cocos/xr/XRRemotePreviewManager.cpp
@@ -22,47 +22,45 @@
THE SOFTWARE.
****************************************************************************/
+#include "application/ApplicationManager.h"
#include "base/Log.h"
#include "base/Macros.h"
-#include "base/std/container/vector.h"
#include "base/std/container/list.h"
#include "base/std/container/string.h"
#include "base/std/container/unordered_map.h"
-#include "application/ApplicationManager.h"
-#include "platform/java/modules/XRInterface.h"
+#include "base/std/container/vector.h"
#include "math/Quaternion.h"
+#include "platform/java/modules/XRInterface.h"
#if CC_USE_XR
-#include "Xr.h"
-#if ANDROID
-#include
-#endif
-#include "XRRemotePreviewManager.h"
-#if CC_USE_WEBSOCKET_SERVER
-#include "network/WebSocketServer.h"
-#endif
+ #include "Xr.h"
+ #if ANDROID
+ #include
+ #endif
+ #include "XRRemotePreviewManager.h"
+ #if CC_USE_WEBSOCKET_SERVER
+ #include "network/WebSocketServer.h"
+ #endif
namespace cc {
-#define SOCKET_PORT 8989
+ #define SOCKET_PORT 8989
// 11259375
const int32_t PACKET_HEAD_CODE = 0x000ABCDEF;
XRRemotePreviewManager::XRRemotePreviewManager() {
-
}
XRRemotePreviewManager::~XRRemotePreviewManager() {
-
}
-#if CC_USE_WEBSOCKET_SERVER
+ #if CC_USE_WEBSOCKET_SERVER
void XRRemotePreviewManager::onClientConnected(const std::shared_ptr &connection) {
CC_LOG_INFO("[XRRemotePreviewManager] onClientConnected.%p", connection.get());
XRDeviceInfo deviceInfo;
deviceInfo.type = static_cast(XRDataPackageType::DPT_MSG_DEVICE_INFO);
memset(deviceInfo.deviceName, 0, sizeof(char) * 32);
strcpy(deviceInfo.deviceName, "XRDevice");
-#if ANDROID
+ #if ANDROID
char man[PROP_VALUE_MAX + 1];
char mod[PROP_VALUE_MAX + 1];
/* A length 0 value indicates that the property is not defined */
@@ -76,7 +74,7 @@ void XRRemotePreviewManager::onClientConnected(const std::shared_ptrgetConnections();
_xr = CC_GET_XR_INTERFACE();
if (_xr) {
@@ -120,40 +118,40 @@ void XRRemotePreviewManager::onConnection(const std::shared_ptrsetOnClose([=](int closeCode, const ccstd::string &closeReason) {
- onClientDisconnected(closeCode, closeReason);
+ onClientDisconnected(closeCode, closeReason);
});
}
-#endif
+ #endif
void XRRemotePreviewManager::start() {
-#if CC_USE_WEBSOCKET_SERVER
+ #if CC_USE_WEBSOCKET_SERVER
_webSocketServer = std::make_shared();
_webSocketServer->setOnBegin([]() {
- CC_LOG_INFO("[XRRemotePreviewManager] onBegin");
+ CC_LOG_INFO("[XRRemotePreviewManager] onBegin");
});
_webSocketServer->setOnEnd([]() {
- CC_LOG_INFO("[XRRemotePreviewManager] onEnd");
+ CC_LOG_INFO("[XRRemotePreviewManager] onEnd");
});
_webSocketServer->setOnClose([](const ccstd::string &msg) {
- CC_LOG_INFO("[XRRemotePreviewManager] onClose.%s", msg.c_str());
+ CC_LOG_INFO("[XRRemotePreviewManager] onClose.%s", msg.c_str());
});
_webSocketServer->setOnListening([](const ccstd::string &msg) {
- CC_LOG_INFO("[XRRemotePreviewManager] onListening.%s", msg.c_str());
+ CC_LOG_INFO("[XRRemotePreviewManager] onListening.%s", msg.c_str());
});
_webSocketServer->setOnError([](const ccstd::string &msg) {
- CC_LOG_INFO("[XRRemotePreviewManager] onError.%s", msg.c_str());
+ CC_LOG_INFO("[XRRemotePreviewManager] onError.%s", msg.c_str());
});
_webSocketServer->setOnConnection(std::bind(&XRRemotePreviewManager::onConnection, this, std::placeholders::_1));
- WebSocketServer::listenAsync(_webSocketServer, SOCKET_PORT, "127.0.0.1", nullptr);
+ WebSocketServer::listenAsync(_webSocketServer, SOCKET_PORT, "127.0.0.1", nullptr);
CC_LOG_INFO("[XRRemotePreviewManager] listenAsync ready!");
-#endif
+ #endif
_isStarted = true;
}
@@ -186,7 +184,7 @@ void XRRemotePreviewManager::packCommonMessageData(const XRCommonMessage &info,
}
void XRRemotePreviewManager::sendMessage(const ccstd::string &message) {
-#if CC_USE_WEBSOCKET_SERVER
+ #if CC_USE_WEBSOCKET_SERVER
if (_webSocketServer && _isConnectionChanged) {
_isConnectionChanged = false;
_wssConnections = _webSocketServer->getConnections();
@@ -209,18 +207,18 @@ void XRRemotePreviewManager::sendMessage(const ccstd::string &message) {
} else {
CC_LOG_INFO("[XRRemotePreviewManager] sendMessage [%s] failed [wss invalid] !!!", message.c_str());
}
-#endif
+ #endif
}
void XRRemotePreviewManager::sendDeviceInfo(const XRDeviceInfo &info) {
-#if CC_USE_WEBSOCKET_SERVER
+ #if CC_USE_WEBSOCKET_SERVER
if (_webSocketServer && _isConnectionChanged) {
_isConnectionChanged = false;
_wssConnections = _webSocketServer->getConnections();
}
if (_webSocketServer && !_wssConnections.empty()) {
- for (auto &wssConn: _wssConnections) {
+ for (auto &wssConn : _wssConnections) {
if (wssConn->getReadyState() == WebSocketServerConnection::ReadyState::OPEN) {
size_t dataLen = 8 + sizeof(info);
char data[dataLen];
@@ -233,18 +231,18 @@ void XRRemotePreviewManager::sendDeviceInfo(const XRDeviceInfo &info) {
} else {
CC_LOG_ERROR("[XRRemotePreviewManager] sendDeviceInfo failed [wss invalid] !!!");
}
-#endif
+ #endif
}
void XRRemotePreviewManager::sendPoseInfo(const XRPoseInfo &info) {
-#if CC_USE_WEBSOCKET_SERVER
+ #if CC_USE_WEBSOCKET_SERVER
if (_webSocketServer && _isConnectionChanged) {
_isConnectionChanged = false;
_wssConnections = _webSocketServer->getConnections();
}
if (_webSocketServer && !_wssConnections.empty()) {
- for (auto &wssConn: _wssConnections) {
+ for (auto &wssConn : _wssConnections) {
if (wssConn->getReadyState() == WebSocketServerConnection::ReadyState::OPEN) {
size_t dataLen = 8 + sizeof(info);
char data[dataLen];
@@ -255,7 +253,7 @@ void XRRemotePreviewManager::sendPoseInfo(const XRPoseInfo &info) {
}
}
}
-#endif
+ #endif
}
void XRRemotePreviewManager::sendControllerKeyInfo(const ControllerInfo::ButtonInfo &info) {
@@ -341,7 +339,7 @@ bool XRRemotePreviewManager::isStarted() const {
void XRRemotePreviewManager::tick() {
if (this->_isStarted) {
xr::XrEntry::getInstance()->getXrPose(_leftEyePose, _rightEyePose, _leftControllerPose, _rightControllerPose);
- _devicePoseInfo.type = static_cast (XRDataPackageType::DPT_MSG_POSE_DATA);
+ _devicePoseInfo.type = static_cast(XRDataPackageType::DPT_MSG_POSE_DATA);
_devicePoseInfo.hmdOrientation[0] = _leftEyePose.qx;
_devicePoseInfo.hmdOrientation[1] = _leftEyePose.qy;
_devicePoseInfo.hmdOrientation[2] = _leftEyePose.qz;
diff --git a/native/cocos/xr/XRRemotePreviewManager.h b/native/cocos/xr/XRRemotePreviewManager.h
index 37505791f7..02ba00b0c4 100644
--- a/native/cocos/xr/XRRemotePreviewManager.h
+++ b/native/cocos/xr/XRRemotePreviewManager.h
@@ -25,23 +25,23 @@
#pragma once
#include
#include
-#include "base/RefCounted.h"
#include "XRCommon.h"
+#include "base/RefCounted.h"
namespace cc {
class IXRInterface;
namespace network {
class WebSocketServer;
class WebSocketServerConnection;
-}
+} // namespace network
using namespace network;
#if CC_USE_XR
enum class XRDataPackageType {
- DPT_MSG_DEVICE_INFO = 1,
- DPT_MSG_POSE_DATA,
- DPT_MSG_CONTROLLER_KEY,
- DPT_MSG_STRING
+ DPT_MSG_DEVICE_INFO = 1,
+ DPT_MSG_POSE_DATA,
+ DPT_MSG_CONTROLLER_KEY,
+ DPT_MSG_STRING
};
enum class XRKeyEventType {
@@ -50,37 +50,37 @@ enum class XRKeyEventType {
KET_GRAB
};
-#pragma pack(1)
+ #pragma pack(1)
struct XRCommonMessage {
- int16_t type;
- ccstd::string message;
+ int16_t type;
+ ccstd::string message;
};
-#pragma pack ()
+ #pragma pack()
-#pragma pack(1)
+ #pragma pack(1)
struct XRDeviceInfo {
- int16_t type;
- int16_t version;
- char deviceName[32];
- int16_t xrVendorType;
- float leftEyeFov[4]; //L-R-D-U
- float rightEyeFov[4];
+ int16_t type;
+ int16_t version;
+ char deviceName[32];
+ int16_t xrVendorType;
+ float leftEyeFov[4]; //L-R-D-U
+ float rightEyeFov[4];
};
-#pragma pack ()
+ #pragma pack()
-#pragma pack(1)
+ #pragma pack(1)
struct XRPoseInfo {
- int16_t type;
- float hmdOrientation[4];
- float hmdPosition[3];
- float leftControllerOrientation[4];
- float leftControllerPosition[3];
- float rightControllerOrientation[4];
- float rightControllerPosition[3];
+ int16_t type;
+ float hmdOrientation[4];
+ float hmdPosition[3];
+ float leftControllerOrientation[4];
+ float leftControllerPosition[3];
+ float rightControllerOrientation[4];
+ float rightControllerPosition[3];
};
-#pragma pack ()
+ #pragma pack()
-#pragma pack(1)
+ #pragma pack(1)
struct XRControllerKeyInfo {
int16_t type;
int16_t keyEventType;
@@ -89,45 +89,47 @@ struct XRControllerKeyInfo {
int16_t stickKeyCode{0};
bool isButtonPressed{false};
};
-#pragma pack ()
+ #pragma pack()
class XRRemotePreviewManager : public RefCounted {
- public:
- XRRemotePreviewManager();
- ~XRRemotePreviewManager() override;
- void start();
- void sendDeviceInfo(const XRDeviceInfo &info);
- void sendPoseInfo(const XRPoseInfo &info);
- void sendControllerKeyInfo(const ControllerInfo::ButtonInfo &info);
- void sendControllerKeyInfo(const ControllerInfo::AxisInfo &info);
- void tick();
- void resume();
- void pause();
- void stop();
- bool isStarted() const;
- private:
- void sendMessage(const ccstd::string &message);
- static void packCommonMessageData(const XRCommonMessage &message, char *data);
- static void packDeviceInfoData(const XRDeviceInfo &info, char *data);
- static void packDevicePoseData(const XRPoseInfo &info, char *data);
- static void packControllerKeyData(const XRControllerKeyInfo &info, char *data);
-#if CC_USE_WEBSOCKET_SERVER
- void onConnection(const std::shared_ptr &connection);
- void onClientConnected(const std::shared_ptr &connection);
- void onClientDisconnected(int closeCode, const ccstd::string &closeReason);
- std::shared_ptr _webSocketServer{nullptr};
- ccstd::vector> _wssConnections;
-#endif
- bool _isStarted{false};
- bool _isConnectionChanged{false};
- IXRInterface *_xr{nullptr};
- cc::xr::XRPose _leftEyePose{cc::xr::XRPose::Type::VIEW_LEFT, true};
- cc::xr::XRPose _rightEyePose{cc::xr::XRPose::Type::VIEW_RIGHT, true};
- cc::xr::XRPose _leftControllerPose{cc::xr::XRPose::Type::HAND_LEFT, true};
- cc::xr::XRPose _rightControllerPose{cc::xr::XRPose::Type::HAND_RIGHT, true};
- XRPoseInfo _devicePoseInfo;
- private:
- CC_DISALLOW_COPY_MOVE_ASSIGN(XRRemotePreviewManager);
+public:
+ XRRemotePreviewManager();
+ ~XRRemotePreviewManager() override;
+ void start();
+ void sendDeviceInfo(const XRDeviceInfo &info);
+ void sendPoseInfo(const XRPoseInfo &info);
+ void sendControllerKeyInfo(const ControllerInfo::ButtonInfo &info);
+ void sendControllerKeyInfo(const ControllerInfo::AxisInfo &info);
+ void tick();
+ void resume();
+ void pause();
+ void stop();
+ bool isStarted() const;
+
+private:
+ void sendMessage(const ccstd::string &message);
+ static void packCommonMessageData(const XRCommonMessage &message, char *data);
+ static void packDeviceInfoData(const XRDeviceInfo &info, char *data);
+ static void packDevicePoseData(const XRPoseInfo &info, char *data);
+ static void packControllerKeyData(const XRControllerKeyInfo &info, char *data);
+ #if CC_USE_WEBSOCKET_SERVER
+ void onConnection(const std::shared_ptr &connection);
+ void onClientConnected(const std::shared_ptr &connection);
+ void onClientDisconnected(int closeCode, const ccstd::string &closeReason);
+ std::shared_ptr _webSocketServer{nullptr};
+ ccstd::vector> _wssConnections;
+ #endif
+ bool _isStarted{false};
+ bool _isConnectionChanged{false};
+ IXRInterface *_xr{nullptr};
+ cc::xr::XRPose _leftEyePose{cc::xr::XRPose::Type::VIEW_LEFT, true};
+ cc::xr::XRPose _rightEyePose{cc::xr::XRPose::Type::VIEW_RIGHT, true};
+ cc::xr::XRPose _leftControllerPose{cc::xr::XRPose::Type::HAND_LEFT, true};
+ cc::xr::XRPose _rightControllerPose{cc::xr::XRPose::Type::HAND_RIGHT, true};
+ XRPoseInfo _devicePoseInfo;
+
+private:
+ CC_DISALLOW_COPY_MOVE_ASSIGN(XRRemotePreviewManager);
};
#endif
diff --git a/native/cocos/xr/Xr.h b/native/cocos/xr/Xr.h
index a5013157ac..385a5a9f05 100644
--- a/native/cocos/xr/Xr.h
+++ b/native/cocos/xr/Xr.h
@@ -30,7 +30,7 @@
#include "XRCommon.h"
#ifndef XR_USE_GRAPHICS_API_OPENGL_ES
-#define XR_USE_GRAPHICS_API_OPENGL_ES 1
+ #define XR_USE_GRAPHICS_API_OPENGL_ES 1
#endif
#ifdef XR_USE_GRAPHICS_API_VULKAN
@@ -158,9 +158,9 @@ public:
virtual void *getXRPointerConfig(int key) = 0;
virtual void getXrPose(cc::xr::XRPose &leftEyePose,
- cc::xr::XRPose &rightEyePose,
- cc::xr::XRPose &leftControllerPose,
- cc::xr::XRPose &rightControllerPose) = 0;
+ cc::xr::XRPose &rightEyePose,
+ cc::xr::XRPose &leftControllerPose,
+ cc::xr::XRPose &rightControllerPose) = 0;
};
} // namespace xr
diff --git a/native/cocos/xr/ar/ARLib.h b/native/cocos/xr/ar/ARLib.h
index 76184d1724..f2fe8ff7e2 100644
--- a/native/cocos/xr/ar/ARLib.h
+++ b/native/cocos/xr/ar/ARLib.h
@@ -33,20 +33,20 @@ class _jobject;
namespace cc {
namespace ar {
-class ARLib : public IARAPI{
+class ARLib : public IARAPI {
public:
ARLib();
~ARLib() override;
void config(int featureMask) override;
uint32_t getSupportMask() override;
void start() override;
- void start(void *env, void *context) override;
+ void start(void* env, void* context) override;
void resume() override;
- void resume(void *env, void *context) override;
+ void resume(void* env, void* context) override;
void pause() override;
void update() override;
int getAPIState() override;
-
+
Pose getCameraPose() override;
Matrix getCameraViewMatrix() override;
Matrix getCameraProjectionMatrix() override;
@@ -115,6 +115,7 @@ public:
float* getUpdatedFacesInfo() override;
float* getRemovedFacesInfo() override;
float* getFaceBlendShapes(int faceRef) override;
+
protected:
#if CC_PLATFORM == CC_PLATFORM_ANDROID
_jobject* _impl{nullptr};
@@ -155,9 +156,9 @@ protected:
float* _faceBlendShapes{nullptr};
#elif CC_PLATFORM == CC_PLATFORM_MAC_IOS
void* _impl{nullptr};
-
+
int _infoLength = 0;
-
+
void* _plane{nullptr};
void* _sceneMesh{nullptr};
void* _imageTracking{nullptr};
diff --git a/native/cocos/xr/ar/ARModule.cpp b/native/cocos/xr/ar/ARModule.cpp
index 7b930d5a0a..1deeae44a9 100644
--- a/native/cocos/xr/ar/ARModule.cpp
+++ b/native/cocos/xr/ar/ARModule.cpp
@@ -22,14 +22,14 @@
THE SOFTWARE.
****************************************************************************/
+#include "ar/ARModule.h"
#include
#include
#include "math/Vec3.h"
-#include "ar/ARModule.h"
#if CC_PLATFORM == CC_PLATFORM_ANDROID || CC_PLATFORM == CC_PLATFORM_MAC_IOS
#include "ar/ARLib.h"
- using ARAPIImpl = cc::ar::ARLib;
+using ARAPIImpl = cc::ar::ARLib;
#elif CC_PLATFORM == CC_PLATFORM_WINDOWS
#include "ar/IARAPI.h"
#endif
@@ -48,7 +48,6 @@ ARModule::ARModule() {
}
ARModule::~ARModule() {
-
}
ARModule* ARModule::get() {
@@ -84,11 +83,11 @@ int ARModule::getAPIState() {
return _impl->getAPIState();
}
-void ARModule::setCameraId(const std::string &id) {
+void ARModule::setCameraId(const std::string& id) {
_cameraId = id;
}
-const std::string &ARModule::getCameraId() const {
+const std::string& ARModule::getCameraId() const {
return _cameraId;
}
diff --git a/native/cocos/xr/ar/ARModule.h b/native/cocos/xr/ar/ARModule.h
index 6cce8467bc..593515837e 100644
--- a/native/cocos/xr/ar/ARModule.h
+++ b/native/cocos/xr/ar/ARModule.h
@@ -47,8 +47,8 @@ public:
void update();
int getAPIState();
- void setCameraId(const std::string &id);
- const std::string &getCameraId() const;
+ void setCameraId(const std::string& id);
+ const std::string& getCameraId() const;
Pose getCameraPose() const;
Matrix getCameraViewMatrix() const;
Matrix getCameraProjectionMatrix() const;
diff --git a/native/extensions/assets-manager/EventAssetsManagerEx.h b/native/extensions/assets-manager/EventAssetsManagerEx.h
index 64b947ff3f..4551523da8 100644
--- a/native/extensions/assets-manager/EventAssetsManagerEx.h
+++ b/native/extensions/assets-manager/EventAssetsManagerEx.h
@@ -109,4 +109,3 @@ private:
};
NS_CC_EXT_END
-