Skip to content

Commit

Permalink
Merge branch 'v3.8.2' into v3.8.2-box2d-wasm-opt
Browse files Browse the repository at this point in the history
  • Loading branch information
lealzhan authored Oct 10, 2023
2 parents cf58bc0 + fcb95b5 commit 48e1a8d
Show file tree
Hide file tree
Showing 42 changed files with 410 additions and 206 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/native-bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
add-to-path: false
local-cache: true
- name: Generate decorators
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
cd native
echo "Generate compile_commands.json & ninja target"
Expand Down
31 changes: 25 additions & 6 deletions .github/workflows/native-compile-platforms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
COCOS_ENGINE_DEV: 1
run: |
NATIVE_ROOT=$GITHUB_WORKSPACE/native
ANDORID_NDK=$ANDROID_NDK_LATEST_HOME
ANDROID_NDK=${{ steps.setup-ndk.outputs.ndk-path }}
NATIVE_DIR=$GITHUB_WORKSPACE/templates/android-template
echo "Compiling Android ... "
cd $GITHUB_WORKSPACE/templates/
Expand All @@ -112,7 +112,7 @@ jobs:
ASSET_DIR=$GITHUB_WORKSPACE/templates/android/build/build-android/
sed -i "s@^PROP_NDK_PATH.*@PROP_NDK_PATH=$ANDORID_NDK@g" gradle.properties
sed -i "s@^PROP_NDK_PATH.*@PROP_NDK_PATH=$ANDROID_NDK@g" gradle.properties
sed -i "s@^APPLICATION_ID.*@APPLICATION_ID=com.cocos.android@g" gradle.properties
sed -i "s@^RES_PATH.*@RES_PATH=$ASSET_DIR@g" gradle.properties
sed -i "s@^COCOS_ENGINE_PATH.*@COCOS_ENGINE_PATH=$NATIVE_ROOT@g" gradle.properties
Expand All @@ -123,7 +123,7 @@ jobs:
sed -i "s@^PROP_APP_ABI.*@PROP_APP_ABI=arm64-v8a@g" gradle.properties
echo "Compile Android - cmake ..."
echo "ANDORID_NDK ${ANDROID_NDK} or ${ANDROID_NDK_HOME}"
echo "ANDROID_NDK ${ANDROID_NDK} or ${ANDROID_NDK_HOME}"
# ./gradlew :CocosGame:assembleDebug --quiet
./gradlew :CocosGame:assembleRelease --quiet
echo "Compile Android Debug Done!"
Expand All @@ -134,6 +134,25 @@ jobs:
(! contains(github.event.pull_request.body, '[X] does not change any runtime related code or build configuration'))
runs-on: ubuntu-latest
steps:
- name: Before free space
run: |
df -h
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@d5af243ce7bacb67384aa6c5b1fc5f169e30903e
with:
tool-cache: true
android: false
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true

- name: After free space
run: |
df -h
- uses: actions/checkout@v2
- name: Download external libraries
shell: bash
Expand All @@ -156,7 +175,7 @@ jobs:
COCOS_ENGINE_DEV: 1
run: |
NATIVE_ROOT=$GITHUB_WORKSPACE/native
ANDORID_NDK=$ANDROID_NDK_LATEST_HOME
ANDROID_NDK=${{ steps.setup-ndk.outputs.ndk-path }}
NATIVE_DIR=$GITHUB_WORKSPACE/templates/android-template
echo "Compiling Android ... "
cd $GITHUB_WORKSPACE/templates/
Expand Down Expand Up @@ -187,7 +206,7 @@ jobs:
ASSET_DIR=$GITHUB_WORKSPACE/templates/android/build/build-android/
sed -i "s@^PROP_NDK_PATH.*@PROP_NDK_PATH=$ANDORID_NDK@g" gradle.properties
sed -i "s@^PROP_NDK_PATH.*@PROP_NDK_PATH=$ANDROID_NDK@g" gradle.properties
sed -i "s@^APPLICATION_ID.*@APPLICATION_ID=com.cocos.android@g" gradle.properties
sed -i "s@^RES_PATH.*@RES_PATH=$ASSET_DIR@g" gradle.properties
sed -i "s@^COCOS_ENGINE_PATH.*@COCOS_ENGINE_PATH=$NATIVE_ROOT@g" gradle.properties
Expand All @@ -199,7 +218,7 @@ jobs:
sed -i "s@^PROP_APP_ABI.*@PROP_APP_ABI=arm64-v8a@g" gradle.properties
echo "Compile Android - cmake ..."
echo "ANDORID_NDK ${ANDROID_NDK} or ${ANDROID_NDK_HOME}"
echo "ANDROID_NDK ${ANDROID_NDK} or ${ANDROID_NDK_HOME}"
./gradlew :CocosGame:assembleDebug --quiet
df -h
./gradlew clean
Expand Down
8 changes: 8 additions & 0 deletions EngineErrorMap.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ Expected 'data' dict, but not found. Config file: %s

Please load the resource first : %s

### 1102

Effect settings not found, effects will not be imported.

### 1103

Success to load scene: %s

### 1200

cocos2d: Director: Error in gettimeofday
Expand Down
4 changes: 2 additions & 2 deletions cocos/core/platform/macro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -987,9 +987,9 @@ interface Macro {

/**
* @en
* Used to set float output, the default value is false.
* Used to set float output render target, more accurate multiple light sources, fog, and translucent effects, custom pipeline only, the default value is false.
* @zh
* 用于开启浮点格式的输出, 默认值为 false。
* 用于开启浮点格式的RT输出, 更精确的多光源、雾化和半透明效果, 仅用于自定义管线, 默认值为 false。
* @default false
*/
ENABLE_FLOAT_OUTPUT: boolean;
Expand Down
36 changes: 22 additions & 14 deletions cocos/game/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { findCanvas, loadJsFile } from 'pal/env';
import { Pacer } from 'pal/pacer';
import { ConfigOrientation } from 'pal/screen-adapter';
import assetManager, { IAssetManagerOptions } from '../asset/asset-manager/asset-manager';
import { EventTarget, AsyncDelegate, sys, macro, VERSION, cclegacy, screen, Settings, settings, assert, garbageCollectionManager, DebugMode, warn, log, _resetDebugSetting } from '../core';
import { EventTarget, AsyncDelegate, sys, macro, VERSION, cclegacy, screen, Settings, settings, assert, garbageCollectionManager, DebugMode, warn, log, _resetDebugSetting, errorID, logID } from '../core';
import { input } from '../input';
import { deviceManager, LegacyRenderMode } from '../gfx';
import { SplashScreen } from './splash-screen';
Expand Down Expand Up @@ -723,6 +723,7 @@ export class Game extends EventTarget {
})
.then((): void => {
if (DEBUG) {
// eslint-disable-next-line no-console
console.time('Init Base');
}
const debugMode = config.debugMode || DebugMode.NONE;
Expand All @@ -735,6 +736,7 @@ export class Game extends EventTarget {
.then((): Promise<void> => settings.init(config.settingsPath, config.overrideSettings))
.then((): Promise<void[]> => {
if (DEBUG) {
// eslint-disable-next-line no-console
console.timeEnd('Init Base');
}
this.emit(Game.EVENT_POST_BASE_INIT);
Expand All @@ -748,6 +750,7 @@ export class Game extends EventTarget {
})
.then((): void => {
if (DEBUG) {
// eslint-disable-next-line no-console
console.time('Init Infrastructure');
}
macro.init();
Expand All @@ -769,6 +772,7 @@ export class Game extends EventTarget {
Layers.init();
this.initPacer();
if (DEBUG) {
// eslint-disable-next-line no-console
console.timeEnd('Init Infrastructure');
}
})
Expand All @@ -795,27 +799,36 @@ export class Game extends EventTarget {
}
const data = effectSettings.data;
if (data === null) {
console.error('Effect settings not found, effects will not be imported.');
errorID(1102);
return;
}
cclegacy.rendering.init(deviceManager.gfxDevice, data);
})
.then((): Promise<any[]> => {
const scriptPackages = settings.querySettings<string[]>(Settings.Category.SCRIPTING, 'scriptPackages');
if (scriptPackages) {
return Promise.all(scriptPackages.map((pack): Promise<any> => import(pack)));
}
return Promise.resolve([]);
})
.then((): Promise<void> => {
if (DEBUG) {
// eslint-disable-next-line no-console
console.time('Init SubSystem');
}
director.init();
return builtinResMgr.loadBuiltinAssets();
})
.then((): Promise<void[]> => {
if (DEBUG) {
// eslint-disable-next-line no-console
console.timeEnd('Init SubSystem');
}
this.emit(Game.EVENT_POST_SUBSYSTEM_INIT);
return this.onPostSubsystemInitDelegate.dispatch();
})
.then((): void => {
console.log(`Cocos Creator v${VERSION}`);
log(`Cocos Creator v${VERSION}`);
this.emit(Game.EVENT_ENGINE_INITED);
this._engineInited = true;
})
Expand All @@ -827,6 +840,7 @@ export class Game extends EventTarget {
})
.then((): Promise<void> => {
if (DEBUG) {
// eslint-disable-next-line no-console
console.time('Init Project');
}
const jsList = settings.querySettings<string[]>(Settings.Category.PLUGINS, 'jsList');
Expand All @@ -838,13 +852,6 @@ export class Game extends EventTarget {
}
return promise;
})
.then((): Promise<any[]> => {
const scriptPackages = settings.querySettings<string[]>(Settings.Category.SCRIPTING, 'scriptPackages');
if (scriptPackages) {
return Promise.all(scriptPackages.map((pack): Promise<any> => import(pack)));
}
return Promise.resolve([]);
})
.then((): Promise<any[]> => this._loadProjectBundles())
.then((): Promise<void> => this._loadCCEScripts())
.then((): void | Promise<void> => this._setupRenderPipeline())
Expand All @@ -855,6 +862,7 @@ export class Game extends EventTarget {
})
.then((): Promise<void[]> => {
if (DEBUG) {
// eslint-disable-next-line no-console
console.timeEnd('Init Project');
}
this.emit(Game.EVENT_POST_PROJECT_INIT);
Expand Down Expand Up @@ -1013,11 +1021,11 @@ export class Game extends EventTarget {
SplashScreen.instance.update(this._calculateDT(false));
} else if (this._shouldLoadLaunchScene) {
this._shouldLoadLaunchScene = false;
const launchScene = settings.querySettings(Settings.Category.LAUNCH, 'launchScene');
const launchScene = settings.querySettings(Settings.Category.LAUNCH, 'launchScene') as string;
if (launchScene) {
// load scene
director.loadScene(launchScene, (): void => {
console.log(`Success to load scene: ${launchScene}`);
logID(1103, launchScene);
this._initTime = performance.now();
director.startAnimation();
this.onStart?.();
Expand Down Expand Up @@ -1098,7 +1106,7 @@ export class Game extends EventTarget {
}

private _setupRenderPipeline (): void | Promise<void> {
const renderPipeline = settings.querySettings(Settings.Category.RENDERING, 'renderPipeline');
const renderPipeline = settings.querySettings(Settings.Category.RENDERING, 'renderPipeline') as string;
if (!renderPipeline) {
return this._setRenderPipeline();
}
Expand All @@ -1124,7 +1132,7 @@ export class Game extends EventTarget {
this._safeEmit(Game.EVENT_RENDERER_INITED);
}

private _safeEmit (event): void {
private _safeEmit (event: string | number): void {
if (EDITOR) {
try {
this.emit(event);
Expand Down
1 change: 1 addition & 0 deletions cocos/gfx/base/define.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ export enum TextureFlagBit {
EXTERNAL_NORMAL = 0x8, // External normal texture
LAZILY_ALLOCATED = 0x10, // Try lazily allocated mode.
MUTABLE_VIEW_FORMAT = 0x40, // texture view as different format
MUTABLE_STORAGE = 0x80, // mutable storage for gl
}

export enum FormatFeatureBit {
Expand Down
5 changes: 4 additions & 1 deletion cocos/gfx/webgl2/webgl2-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ export class WebGL2CmdDraw extends WebGL2CmdObject {
}

public clear (): void {
// noop
}
}

Expand Down Expand Up @@ -1087,6 +1088,8 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2Device, gpuTexture: IW
w = Math.max(1, w >> 1);
h = Math.max(1, h >> 1);
}
} else if (gpuTexture.flags & TextureFlagBit.MUTABLE_STORAGE) {
gl.texImage2D(gl.TEXTURE_2D, 0, gpuTexture.glInternalFmt, w, h, 0, gpuTexture.glFormat, gpuTexture.glType, null);
} else {
gl.texStorage2D(gl.TEXTURE_2D, gpuTexture.mipLevel, gpuTexture.glInternalFmt, w, h);
}
Expand Down Expand Up @@ -2849,7 +2852,7 @@ export function WebGL2CmdFuncCopyTexImagesToTexture (

switch (gpuTexture.glTarget) {
case gl.TEXTURE_2D: {
if (toUseTexImage2D(texImages, regions)) {
if ((gpuTexture.flags & TextureFlagBit.MUTABLE_STORAGE) || toUseTexImage2D(texImages, regions)) {
gl.texImage2D(
gl.TEXTURE_2D,
regions[0].texSubres.mipLevel,
Expand Down
24 changes: 19 additions & 5 deletions cocos/physics/bullet/constraints/bullet-configurable-constraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,25 @@ export class BulletConfigurableConstraint extends BulletConstraint implements IC
const axisY = cs.secondaryAxis;
const axisZ = Vec3.cross(CC_V3_1, axisX, axisY);

const mat = Mat4.set(CC_MAT4_0,
axisX.x, axisX.y, axisX.z, 0,
axisY.x, axisY.y, axisY.z, 0,
axisZ.x, axisZ.y, axisZ.z, 0,
0, 0, 0, 1);
const mat = Mat4.set(
CC_MAT4_0,
axisX.x,
axisX.y,
axisX.z,
0,
axisY.x,
axisY.y,
axisY.z,
0,
axisZ.x,
axisZ.y,
axisZ.z,
0,
0,
0,
0,
1,
);
mat.getRotation(rot_0);

cocos2BulletQuat(quat, rot_0);
Expand Down
2 changes: 1 addition & 1 deletion cocos/physics/cannon/cannon-rigid-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class CannonRigidBody implements IRigidBody {
this._wakeUpIfSleep();
}

useCCD (value:boolean): void {
useCCD (value: boolean): void {
this.impl.ccdSpeedThreshold = value ? 0.01 : -1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import { PhysicsSystem } from '../../physics-system';
const v3_0 = new Vec3(0, 0, 0);
const scaledCenter = new Vec3(0, 0, 0);

type Callback = (...args: any[]) => any;

/**
* @en
* Base class for Character Controller component.
Expand Down Expand Up @@ -374,8 +376,12 @@ export class CharacterController extends Eventify(Component) {
* @param callback - The event callback, signature:`(event?:ICollisionEvent|ITriggerEvent)=>void`.
* @param target - The event callback target.
*/
public on<TFunction extends (...any) => void>(type: CharacterTriggerEventType | CharacterCollisionEventType,
callback: TFunction, target?, once?: boolean): any {
public on<TFunction extends Callback> (
type: CharacterTriggerEventType | CharacterCollisionEventType,
callback: TFunction,
target?,
once?: boolean,
): any {
const ret = super.on(type, callback, target, once);
this._updateNeedEvent(type);
return ret;
Expand All @@ -390,7 +396,7 @@ export class CharacterController extends Eventify(Component) {
* @param callback - The event callback, signature:`(event?:ICollisionEvent|ITriggerEvent)=>void`.
* @param target - The event callback target.
*/
public off (type: CharacterTriggerEventType | CharacterCollisionEventType, callback?: (...any) => void, target?): void {
public off (type: CharacterTriggerEventType | CharacterCollisionEventType, callback?: Callback, target?): void {
super.off(type, callback, target);
this._updateNeedEvent();
}
Expand All @@ -404,8 +410,11 @@ export class CharacterController extends Eventify(Component) {
* @param callback - The event callback, signature:`(event?:ICollisionEvent|ITriggerEvent)=>void`.
* @param target - The event callback target.
*/
public once<TFunction extends (...any) => void>(type: CharacterTriggerEventType | CharacterCollisionEventType,
callback: TFunction, target?): any {
public once<TFunction extends Callback> (
type: CharacterTriggerEventType | CharacterCollisionEventType,
callback: TFunction,
target?,
): any {
// TODO: callback invoker now is a entity, after `once` will not calling the upper `off`.
const ret = super.once(type, callback, target);
this._updateNeedEvent(type);
Expand Down
Loading

0 comments on commit 48e1a8d

Please sign in to comment.