Merge pull request #9223 from cocos-creator/v3.3.1

sync V3.3.1
This commit is contained in:
Santy-Wang
2021-08-21 14:26:32 +08:00
committed by GitHub
13 changed files with 81 additions and 79 deletions
+1 -3
View File
@@ -150,9 +150,7 @@ export class DrawBatch2D {
mtlPass.update();
if (mtlPass.hash === passInUse.hash) {
continue;
}
// Hack: Cause pass.hash can not check all pass value
if (!dss) { dss = mtlPass.depthStencilState; dssHash = 0; }
if (!bs) { bs = mtlPass.blendState; bsHash = 0; }
+2 -1
View File
@@ -35,6 +35,7 @@ import { decodeUuid } from './helper';
import { files, parsed } from './shared';
import { dependMap, nativeDependMap } from './depend-maps';
import { assertIsNonNullable } from '../data/utils/asserts';
import { CCON } from '../data/ccon';
export interface IDependencies {
nativeDep?: Record<string, any>;
@@ -146,7 +147,7 @@ export class DependUtil {
*/
public parse (uuid: string, json: any): IDependencies {
let out: IDependencies | null = null;
if (Array.isArray(json) || json.__type__) {
if (Array.isArray(json) || json.__type__ || json instanceof CCON) {
if (this._depends.has(uuid)) {
return this._depends.get(uuid)!;
}
+1 -1
View File
@@ -106,7 +106,7 @@ export function getUrlWithUuid (uuid: string, options?: IOptions | null): string
*
*/
export function isScene (asset) {
return asset && (asset instanceof legacyCC.SceneAsset || asset instanceof legacyCC.Scene);
return !!asset && (asset instanceof legacyCC.SceneAsset || asset instanceof legacyCC.Scene);
}
/**
+2 -2
View File
@@ -87,7 +87,7 @@ export function parse (task: Task) {
if (bundles.has(item.bundle)) {
bundles.get(item.bundle)!.config.getDirWithPath(item.dir, item.type, infos);
for (const assetInfo of infos) {
input.push({ uuid: assetInfo.uuid, __isNative__: false, ext: '.json', bundle: item.bundle });
input.push({ uuid: assetInfo.uuid, __isNative__: false, ext: assetInfo.extension || '.json', bundle: item.bundle });
}
infos.length = 0;
}
@@ -113,7 +113,7 @@ export function parse (task: Task) {
out.uuid = info.uuid;
out.info = info;
}
out.ext = item.ext || '.json';
out.ext = item.ext || info?.extension || '.json';
break;
case RequestType.SCENE:
if (!item.bundle) {
+31 -53
View File
@@ -1282,12 +1282,8 @@ export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGL
for (let u = 0; u < block.members.length; ++u) {
const uniform = block.members[u];
const glType = GFXTypeToWebGLType(uniform.type, gl);
const Ctor = GFXTypeToTypedArrayCtor(uniform.type);
const stride = WebGLGetTypeSize(glType, gl);
const size = stride * uniform.count;
const begin = glBlock.size / 4;
const count = size / 4;
const array = new Ctor(count);
glBlock.glUniforms[u] = {
binding: -1,
@@ -1296,42 +1292,13 @@ export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGL
stride,
count: uniform.count,
size,
offset: glBlock.size,
offset: 0,
glType,
glLoc: -1,
array,
begin,
array: null!,
};
glBlock.size += size;
}
/*
glBlock.buffer = new ArrayBuffer(glBlock.size);
for (let k = 0; k < glBlock.glUniforms.length; k++) {
const glUniform = glBlock.glUniforms[k];
switch (glUniform.glType) {
case gl.BOOL:
case gl.BOOL_VEC2:
case gl.BOOL_VEC3:
case gl.BOOL_VEC4:
case gl.INT:
case gl.INT_VEC2:
case gl.INT_VEC3:
case gl.INT_VEC4:
case gl.SAMPLER_2D:
case gl.SAMPLER_CUBE: {
glUniform.vi32 = new Int32Array(glBlock.buffer);
break;
}
default: {
glUniform.vf32 = new Float32Array(glBlock.buffer);
}
}
}
*/
}
}
@@ -1376,8 +1343,6 @@ export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGL
varName = uniformInfo.name;
}
// let stride = WebGLGetTypeSize(info.type);
// build uniform block mapping
for (let j = 0; j < gpuShader.glBlocks.length; j++) {
const glBlock = gpuShader.glBlocks[j];
@@ -1385,19 +1350,32 @@ export function WebGLCmdFuncCreateShader (device: WebGLDevice, gpuShader: IWebGL
for (let k = 0; k < glBlock.glUniforms.length; k++) {
const glUniform = glBlock.glUniforms[k];
if (glUniform.name === varName) {
// let varSize = stride * info.size;
glUniform.glLoc = glLoc;
glBlock.glActiveUniforms.push(glUniform);
glUniform.count = uniformInfo.size;
glUniform.size = glUniform.stride * glUniform.count;
glUniform.array = new (GFXTypeToTypedArrayCtor(glUniform.type))(glUniform.size / 4);
glBlock.glActiveUniforms.push(glUniform);
break;
}
}
} // for
}
}
}
}
} // for
}
// calculate offset & size
// WARNING: we can't handle inactive uniform arrays with wrong input sizes
// and there is no way to detect that for now
for (let j = 0; j < gpuShader.glBlocks.length; j++) {
const glBlock = gpuShader.glBlocks[j];
for (let k = 0; k < glBlock.glUniforms.length; k++) {
const glUniform = glBlock.glUniforms[k];
glUniform.offset = glBlock.size / 4;
glBlock.size += glUniform.size;
}
}
// texture unit index mapping optimization
const glActiveSamplers: IWebGLGPUUniformSamplerTexture[] = [];
@@ -2025,7 +2003,7 @@ export function WebGLCmdFuncBindStates (
case gl.BOOL:
case gl.INT: {
for (let u = 0; u < glUniform.array.length; ++u) {
const idx = glUniform.begin + offset + u;
const idx = glUniform.offset + offset + u;
if (vf32[idx] !== glUniform.array[u]) {
for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) {
glUniform.array[n] = vf32[m];
@@ -2039,7 +2017,7 @@ export function WebGLCmdFuncBindStates (
case gl.BOOL_VEC2:
case gl.INT_VEC2: {
for (let u = 0; u < glUniform.array.length; ++u) {
const idx = glUniform.begin + offset + u;
const idx = glUniform.offset + offset + u;
if (vf32[idx] !== glUniform.array[u]) {
for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) {
glUniform.array[n] = vf32[m];
@@ -2053,7 +2031,7 @@ export function WebGLCmdFuncBindStates (
case gl.BOOL_VEC3:
case gl.INT_VEC3: {
for (let u = 0; u < glUniform.array.length; ++u) {
const idx = glUniform.begin + offset + u;
const idx = glUniform.offset + offset + u;
if (vf32[idx] !== glUniform.array[u]) {
for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) {
glUniform.array[n] = vf32[m];
@@ -2067,7 +2045,7 @@ export function WebGLCmdFuncBindStates (
case gl.BOOL_VEC4:
case gl.INT_VEC4: {
for (let u = 0; u < glUniform.array.length; ++u) {
const idx = glUniform.begin + offset + u;
const idx = glUniform.offset + offset + u;
if (vf32[idx] !== glUniform.array[u]) {
for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) {
glUniform.array[n] = vf32[m];
@@ -2080,7 +2058,7 @@ export function WebGLCmdFuncBindStates (
}
case gl.FLOAT: {
for (let u = 0; u < glUniform.array.length; ++u) {
const idx = glUniform.begin + offset + u;
const idx = glUniform.offset + offset + u;
if (vf32[idx] !== glUniform.array[u]) {
for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) {
glUniform.array[n] = vf32[m];
@@ -2093,7 +2071,7 @@ export function WebGLCmdFuncBindStates (
}
case gl.FLOAT_VEC2: {
for (let u = 0; u < glUniform.array.length; ++u) {
const idx = glUniform.begin + offset + u;
const idx = glUniform.offset + offset + u;
if (vf32[idx] !== glUniform.array[u]) {
for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) {
glUniform.array[n] = vf32[m];
@@ -2106,7 +2084,7 @@ export function WebGLCmdFuncBindStates (
}
case gl.FLOAT_VEC3: {
for (let u = 0; u < glUniform.array.length; ++u) {
const idx = glUniform.begin + offset + u;
const idx = glUniform.offset + offset + u;
if (vf32[idx] !== glUniform.array[u]) {
for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) {
glUniform.array[n] = vf32[m];
@@ -2119,7 +2097,7 @@ export function WebGLCmdFuncBindStates (
}
case gl.FLOAT_VEC4: {
for (let u = 0; u < glUniform.array.length; ++u) {
const idx = glUniform.begin + offset + u;
const idx = glUniform.offset + offset + u;
if (vf32[idx] !== glUniform.array[u]) {
for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) {
glUniform.array[n] = vf32[m];
@@ -2132,7 +2110,7 @@ export function WebGLCmdFuncBindStates (
}
case gl.FLOAT_MAT2: {
for (let u = 0; u < glUniform.array.length; ++u) {
const idx = glUniform.begin + offset + u;
const idx = glUniform.offset + offset + u;
if (vf32[idx] !== glUniform.array[u]) {
for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) {
glUniform.array[n] = vf32[m];
@@ -2145,7 +2123,7 @@ export function WebGLCmdFuncBindStates (
}
case gl.FLOAT_MAT3: {
for (let u = 0; u < glUniform.array.length; ++u) {
const idx = glUniform.begin + offset + u;
const idx = glUniform.offset + offset + u;
if (vf32[idx] !== glUniform.array[u]) {
for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) {
glUniform.array[n] = vf32[m];
@@ -2158,7 +2136,7 @@ export function WebGLCmdFuncBindStates (
}
case gl.FLOAT_MAT4: {
for (let u = 0; u < glUniform.array.length; ++u) {
const idx = glUniform.begin + offset + u;
const idx = glUniform.offset + offset + u;
if (vf32[idx] !== glUniform.array[u]) {
for (let n = u, m = idx; n < glUniform.array.length; ++n, ++m) {
glUniform.array[n] = vf32[m];
@@ -131,7 +131,6 @@ export interface IWebGLGPUUniform {
glType: GLenum;
glLoc: WebGLUniformLocation;
array: Int32Array | Float32Array;
begin: number;
}
export interface IWebGLGPUUniformBlock {
+1 -1
View File
@@ -173,7 +173,7 @@ if (DEV) {
legacyCC._Test = {};
}
const engineVersion = '3.4.0';
const engineVersion = '3.3.1';
/**
* The current version of Cocos2d being used.<br/>
+2 -1
View File
@@ -53,7 +53,8 @@ export class UIPhase {
}
if (!visible) continue;
const count = batch.passes.length;
// shaders.length always equals actual used passes.length
const count = batch.shaders.length;
for (let j = 0; j < count; j++) {
const pass = batch.passes[j];
if (pass.phase !== this._phaseID) continue;
+6
View File
@@ -100,6 +100,12 @@ export class Scene extends BaseNode {
protected declare _nativeObj: NativeScene | null;
protected _lpos = Vec3.ZERO;
protected _lrot = Quat.IDENTITY;
protected _lscale = Vec3.ONE;
protected _updateScene () {
this._scene = this;
}
+6 -12
View File
@@ -50,16 +50,12 @@
"endSizeVar": 0,
"positionType": 0,
"sourcePos": {
"_array": {
"0": 0,
"1": 0
}
"x": 0,
"y": 0
},
"posVar": {
"_array": {
"0": 7,
"1": 7
}
"x": 7,
"y": 7
},
"angle": 360,
"angleVar": 360,
@@ -69,10 +65,8 @@
"endSpinVar": -142.11000061035156,
"emitterMode": 0,
"gravity": {
"_array": {
"0": 0.25,
"1": 0.8600000143051147
}
"x": 0.25,
"y": 0.8600000143051147
},
"speed": 0,
"speedVar": 190.7899932861328,
+11 -3
View File
@@ -164,6 +164,10 @@ const Elements = {
length = 10;
}
if (!Array.isArray(this.meta.userData.dependencies)) {
this.meta.userData.dependencies = [];
}
while (this.meta.userData.dependencies.length < length) {
this.meta.userData.dependencies.push('');
}
@@ -172,6 +176,10 @@ const Elements = {
this.meta.userData.dependencies.pop();
}
if (!this.meta.userData.dependencies.length) {
this.meta.userData.dependencies = undefined;
}
this.dispatch('change');
Elements.dependencies.update.call(this);
@@ -188,14 +196,14 @@ const Elements = {
return;
}
this.$.dependenciesContent.innerText = '';
if (!Array.isArray(this.meta.userData.dependencies)) {
this.meta.userData.dependencies = [];
return;
}
const length = this.meta.userData.dependencies.length;
this.$.dependenciesInput.value = length;
this.$.dependenciesContent.innerText = '';
for (let i = 0; i < length; i++) {
const child = document.createElement('ui-asset');
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "cocos-creator",
"version": "3.4.0",
"version": "3.3.1",
"description": "Cocos Creator is a cross-platform 2D & 3D game engine written in TypeScript, licensed under MIT.",
"homepage": "http://www.cocos.com",
"license": "MIT",
+17
View File
@@ -0,0 +1,17 @@
import { Node, Scene} from "../../cocos/core/scene-graph"
import {Vec3} from "../../cocos/core/math"
describe(`Node`, () => {
test('@inverseTransformPoint', () => {
let scene = new Scene('temp');
let parentNode = new Node();
let subNode = new Node();
parentNode.setPosition(20, -30, 100);
subNode.setPosition(55, 35, 22);
parentNode.parent = scene;
subNode.parent = parentNode;
let p = new Vec3(100, 200, 0);
subNode.inverseTransformPoint(p, p);
expect(p).toStrictEqual(new Vec3(25, 195, -122));
});
});