Skip to content

Commit

Permalink
Merge pull request cocos#44 from dumganhar/v3.3.0-native
Browse files Browse the repository at this point in the history
Update jsb hacking code, editor compilation for native works
  • Loading branch information
minggo authored Oct 22, 2021
2 parents d800b2d + 9a2ca5f commit 797a0e5
Show file tree
Hide file tree
Showing 21 changed files with 666 additions and 69 deletions.
14 changes: 13 additions & 1 deletion cc.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,25 @@
"overrides": {
"cocos/core/pipeline/index.ts": "cocos/core/pipeline/index.jsb.ts",
"cocos/core/renderer/core/native-pools.ts": "cocos/core/renderer/core/native-pools.jsb.ts",
"cocos/core/renderer/core/material-instance.ts": "cocos/core/renderer/core/material-instance.jsb.ts",
"cocos/core/renderer/core/pass.ts": "cocos/core/renderer/core/pass.jsb.ts",
"cocos/core/renderer/core/render-window.ts": "cocos/core/renderer/core/render-window.jsb.ts",
"cocos/core/renderer/core/samper-lib.ts": "cocos/core/renderer/core/sampler.jsb.ts",
"cocos/core/renderer/scene/camera.ts": "cocos/core/renderer/scene/camera.jsb.ts",
"cocos/core/renderer/scene/model.ts": "cocos/core/renderer/scene/model.jsb.ts",
"cocos/core/renderer/scene/render-scene.ts": "cocos/core/renderer/scene/render-scene.jsb.ts",
"cocos/core/renderer/scene/submodel.ts": "cocos/core/renderer/scene/submodel.jsb.ts",
"cocos/core/renderer/scene/index.ts": "cocos/core/renderer/scene/index.jsb.ts",
"cocos/core/gfx/index.ts": "cocos/core/gfx/index.jsb.ts",
"cocos/core/gfx/pipeline-state.ts": "cocos/core/gfx/pipeline-state.jsb.ts",
"cocos/spine/index.ts": "cocos/spine/index.jsb.ts",
"cocos/dragon-bones/index.ts": "cocos/dragon-bones/index.jsb.ts",
"cocos/physics/physx/instantiate.ts": "cocos/physics/physx/instantiate.jsb.ts",
"cocos/core/scene-graph/index.ts": "cocos/core/scene-graph/index.jsb.ts",
"cocos/core/scene-graph/base-node.ts": "cocos/core/scene-graph/base-node.jsb.ts",
"cocos/core/scene-graph/node.ts": "cocos/core/scene-graph/node.jsb.ts",
"cocos/core/scene-graph/find.ts": "cocos/core/scene-graph/find.jsb.ts",
"cocos/core/scene-graph/scene-globals.ts": "cocos/core/scene-graph/scene-globals.jsb.ts",
"cocos/core/scene-graph/index.ts": "cocos/core/scene-graph/index.jsb.ts",
"cocos/core/root.ts": "cocos/core/root.jsb.ts"
}
},
Expand Down
1 change: 0 additions & 1 deletion cocos/2d/framework/renderable-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { ccenum } from '../../core/value-types/enum';
import { builtinResMgr } from '../../core/builtin';
import { Material } from '../../core/assets';
import { BlendFactor, BlendState, BlendTarget } from '../../core/gfx';
import { IMaterialInstanceInfo } from '../../core/renderer/core/material-instance';
import { IAssembler, IAssemblerManager } from '../renderer/base';
import { RenderData } from '../renderer/render-data';
import { Batcher2D } from '../renderer/batcher-2d';
Expand Down
34 changes: 34 additions & 0 deletions cocos/core/renderer/core/material-instance.jsb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
Copyright (c) 2021 Xiamen Yaji Software Co., Ltd.
https://www.cocos.com/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import { Material } from "../../assets";
import { RenderableComponent } from "../../components";

export interface IMaterialInstanceInfo {
parent: Material;
owner?: RenderableComponent;
subModelIdx?: number;
}
export const MaterialInstance = jsb.MaterialInstance;
1 change: 0 additions & 1 deletion cocos/core/renderer/core/native-pools.jsb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
THE SOFTWARE.
*/


declare const jsb: any;

export const NativeBufferPool = jsb.NativeBufferPool;
Expand Down
48 changes: 48 additions & 0 deletions cocos/core/renderer/core/pass.jsb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
Copyright (c) 2021 Xiamen Yaji Software Co., Ltd.
https://www.cocos.com/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import { IPassInfo, IPassStates } from "../../assets/effect-asset";
import { MacroRecord } from "./pass-utils";

export interface IPassInfoFull extends IPassInfo {
// generated part
passIndex: number;
defines: MacroRecord;
stateOverrides?: PassOverrides;
}
export type PassOverrides = RecursivePartial<IPassStates>;

export interface IMacroPatch {
name: string;
value: boolean | number | string;
}

export enum BatchingSchemes {
NONE = 0,
INSTANCING = 1,
VB_MERGING = 2,
}

export const Pass = jsb.Pass;
37 changes: 37 additions & 0 deletions cocos/core/renderer/core/render-window.jsb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Copyright (c) 2021 Xiamen Yaji Software Co., Ltd.
https://www.cocos.com/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import { RenderPassInfo } from "../../gfx";

export interface IRenderWindowInfo {
title?: string;
width: number;
height: number;
renderPassInfo: RenderPassInfo;
swapchainBufferIndices?: number;
shouldSyncSizeWithSwapchain?: boolean;
}

export const RenderWindow = jsb.RenderWindow;
32 changes: 32 additions & 0 deletions cocos/core/renderer/core/sampler-lib.jsb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Copyright (c) 2021 Xiamen Yaji Software Co., Ltd.
https://www.cocos.com/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import { legacyCC } from "../../global-exports";

export const Pass = jsb.Pass;

const SamplerLib = nr.SamplerLib;
export const samplerLib = new SamplerLib();
legacyCC.samplerLib = samplerLib;
57 changes: 57 additions & 0 deletions cocos/core/renderer/index.jsb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
Copyright (c) 2021 Xiamen Yaji Software Co., Ltd.
https://www.cocos.com/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import config from './config';

import * as scene from './scene';

import './scene/deprecated';
import { legacyCC } from "../global-exports";
import { RenderableComponent } from "../components";

export { createIA } from './utils';

const addStage = config.addStage;
export { addStage };

export * from './core/constants';
export * from './core/pass-utils';
export const Pass = jsb.Pass;
const ProgramLib = jsb.ProgramLib;
export const programLib = new ProgramLib();
legacyCC.programLib = programLib;
export * from "./core/sampler-lib";
export * from './core/texture-buffer-pool';

export interface IMaterialInstanceInfo {
parent: any;
owner?: RenderableComponent;
subModelIdx?: number;
}
export const MaterialInstance = jsb.MaterialInstance;
export const PassInstance = jsb.PassInstance;

export * from './core/memory-pools';
export { scene };
105 changes: 105 additions & 0 deletions cocos/core/renderer/scene/camera.jsb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
Copyright (c) 2021 Xiamen Yaji Software Co., Ltd.
https://www.cocos.com/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import { RenderWindow } from "../core/render-window";
import { ClearFlagBit } from "../../gfx";

export enum CameraFOVAxis {
VERTICAL,
HORIZONTAL,
}

export enum CameraProjection {
ORTHO,
PERSPECTIVE,
}

export enum CameraAperture {
F1_8,
F2_0,
F2_2,
F2_5,
F2_8,
F3_2,
F3_5,
F4_0,
F4_5,
F5_0,
F5_6,
F6_3,
F7_1,
F8_0,
F9_0,
F10_0,
F11_0,
F13_0,
F14_0,
F16_0,
F18_0,
F20_0,
F22_0,
}

export enum CameraISO {
ISO100,
ISO200,
ISO400,
ISO800,
}

export enum CameraShutter {
D1,
D2,
D4,
D8,
D15,
D30,
D60,
D125,
D250,
D500,
D1000,
D2000,
D4000,
}

const FSTOPS: number[] = [1.8, 2.0, 2.2, 2.5, 2.8, 3.2, 3.5, 4.0, 4.5, 5.0, 5.6, 6.3, 7.1, 8.0, 9.0, 10.0, 11.0, 13.0, 14.0, 16.0, 18.0, 20.0, 22.0];
const SHUTTERS: number[] = [1.0, 1.0 / 2.0, 1.0 / 4.0, 1.0 / 8.0, 1.0 / 15.0, 1.0 / 30.0, 1.0 / 60.0, 1.0 / 125.0,
1.0 / 250.0, 1.0 / 500.0, 1.0 / 1000.0, 1.0 / 2000.0, 1.0 / 4000.0];
const ISOS: number[] = [100.0, 200.0, 400.0, 800.0];

export interface ICameraInfo {
name: string;
node: Node;
projection: number;
targetDisplay?: number;
window?: RenderWindow | null;
priority: number;
pipeline?: string;
}

export const SKYBOX_FLAG = ClearFlagBit.STENCIL << 1;

export const Camera = jsb.Camera;
Loading

0 comments on commit 797a0e5

Please sign in to comment.