mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-03 01:12:42 +08:00
@@ -1972,3 +1972,7 @@ The current buffer beyond the limit in ui static component, please reduce the am
|
||||
### 9301
|
||||
|
||||
The UI has not been initialized
|
||||
|
||||
### 10001
|
||||
|
||||
The sub-mesh contains %d vertices, which beyonds the capability (%d vertices most) of renderer of your platform.
|
||||
@@ -85,4 +85,4 @@ export abstract class AudioPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
cc.AudioPlayer = AudioPlayer;
|
||||
cc.internal.AudioPlayer = AudioPlayer;
|
||||
|
||||
@@ -40,12 +40,13 @@ import {
|
||||
GFXMemoryUsageBit,
|
||||
GFXPrimitiveMode,
|
||||
} from '../gfx/define';
|
||||
import { GFXDevice } from '../gfx/device';
|
||||
import { GFXDevice, GFXFeature } from '../gfx/device';
|
||||
import { IGFXAttribute } from '../gfx/input-assembler';
|
||||
import { DataPoolManager } from '../renderer/data-pool-manager';
|
||||
import { murmurhash2_32_gc } from '../utils/murmurhash2_gc';
|
||||
import { Asset } from './asset';
|
||||
import { postLoadMesh } from './utils/mesh-utils';
|
||||
import { warnID } from '../platform/debug';
|
||||
|
||||
function getIndexStrideCtor (stride: number) {
|
||||
switch (stride) {
|
||||
@@ -397,15 +398,29 @@ export class Mesh extends Asset {
|
||||
if (prim.indexView) {
|
||||
const idxView = prim.indexView;
|
||||
|
||||
let dstStride = idxView.stride;
|
||||
if (dstStride === 4 && !gfxDevice.hasFeature(GFXFeature.ELEMENT_INDEX_UINT)) {
|
||||
const vertexCount = this._struct.vertexBundles[prim.vertexBundelIndices[0]].view.count;
|
||||
if (vertexCount >= 2 ** 16) {
|
||||
warnID(10001, vertexCount, 2 ** 16);
|
||||
continue; // Ignore this primitive
|
||||
} else {
|
||||
dstStride = 2; // Reduce to short.
|
||||
}
|
||||
}
|
||||
|
||||
indexBuffer = gfxDevice.createBuffer({
|
||||
usage: GFXBufferUsageBit.INDEX | GFXBufferUsageBit.TRANSFER_DST,
|
||||
memUsage: GFXMemoryUsageBit.HOST | GFXMemoryUsageBit.DEVICE,
|
||||
size: idxView.length,
|
||||
stride: idxView.stride,
|
||||
stride: dstStride,
|
||||
});
|
||||
indexBuffers.push(indexBuffer);
|
||||
|
||||
ib = new (getIndexStrideCtor(idxView.stride))(buffer, idxView.offset, idxView.count);
|
||||
if (idxView.stride !== dstStride) {
|
||||
ib = getIndexStrideCtor(dstStride).from(ib);
|
||||
}
|
||||
if (this.loaded) {
|
||||
indexBuffer.update(ib);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,11 @@ export enum GFXFeature {
|
||||
FORMAT_ASTC,
|
||||
MSAA,
|
||||
COUNT,
|
||||
|
||||
/**
|
||||
* Allow vertex index to be unsigned 32 bits integer type.
|
||||
*/
|
||||
ELEMENT_INDEX_UINT,
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -373,7 +373,11 @@ export class WebGLGFXDevice extends GFXDevice {
|
||||
this._features[GFXFeature.MSAA] = false;
|
||||
|
||||
if (this._OES_vertex_array_object) {
|
||||
if (sys.platform !== sys.WECHAT_GAME || sys.os !== sys.OS_IOS) { this._useVAO = true; }
|
||||
if ( !CC_RUNTIME_BASED && (sys.platform !== sys.WECHAT_GAME || sys.os !== sys.OS_IOS)) { this._useVAO = true; }
|
||||
}
|
||||
|
||||
if (this._OES_element_index_uint) {
|
||||
this._features[GFXFeature.ELEMENT_INDEX_UINT] = true;
|
||||
}
|
||||
|
||||
console.info('RENDERER: ' + this._renderer);
|
||||
|
||||
@@ -249,6 +249,7 @@ export class WebGL2GFXDevice extends GFXDevice {
|
||||
this._features[GFXFeature.FORMAT_D24S8] = true;
|
||||
this._features[GFXFeature.FORMAT_ETC2] = true;
|
||||
this._features[GFXFeature.MSAA] = true;
|
||||
this._features[GFXFeature.ELEMENT_INDEX_UINT] = true;
|
||||
|
||||
if (this._EXT_color_buffer_float) {
|
||||
this._features[GFXFeature.COLOR_FLOAT] = true;
|
||||
|
||||
@@ -32,7 +32,6 @@ import * as math from './math';
|
||||
import * as memop from './memop';
|
||||
cc.math = math;
|
||||
cc.geometry = geometry;
|
||||
cc.memop = memop;
|
||||
|
||||
export { math, memop, geometry };
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import { frustum, intersect } from '../geom-utils';
|
||||
import { Mat4, Vec3, Quat } from '../math';
|
||||
import { Mat4, Quat, Vec3 } from '../math';
|
||||
import { Camera, Light, Model } from '../renderer';
|
||||
import { DirectionalLight } from '../renderer/scene/directional-light';
|
||||
import { SphereLight } from '../renderer/scene/sphere-light';
|
||||
@@ -24,7 +24,7 @@ export function cullSphereLight (light: SphereLight, model: Model) {
|
||||
|
||||
export function cullSpotLight (light: SpotLight, model: Model) {
|
||||
return cullLight(light, model) || !!(model.worldBounds &&
|
||||
(!intersect.aabb_aabb(model.worldBounds, light.aabb) || !intersect.aabb_frustum(model.worldBounds, light.frustum)));
|
||||
(!intersect.aabb_aabb(model.worldBounds, light.aabb) || !intersect.aabb_frustum(model.worldBounds, light.frustum)));
|
||||
}
|
||||
|
||||
export const cullSceneWithDirectionalLight = (() => {
|
||||
|
||||
@@ -295,8 +295,8 @@ export class ForwardPipeline extends RenderPipeline {
|
||||
* 对每个模型裁剪光源。
|
||||
* @param model 模型。
|
||||
*/
|
||||
private cullLightPerModel(model: Model) {
|
||||
_tempLightIndex.splice(0);
|
||||
private cullLightPerModel (model: Model) {
|
||||
_tempLightIndex.length = 0;
|
||||
for (let i = 0; i < this._validLights.length; i++) {
|
||||
let isCulled = false;
|
||||
switch (this._validLights[i].type) {
|
||||
@@ -320,7 +320,7 @@ export class ForwardPipeline extends RenderPipeline {
|
||||
}
|
||||
}
|
||||
_tempLightIndex.sort(this.sortLight);
|
||||
this._lightIndices.push(..._tempLightIndex);
|
||||
Array.prototype.push.apply(this._lightIndices, _tempLightIndex);
|
||||
}
|
||||
|
||||
private sortLight(a, b) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { aabb } from '../../geom-utils';
|
||||
import { Vec3 } from '../../math';
|
||||
import { INode } from '../../utils/interfaces';
|
||||
import { Light, LightType, nt2lm } from './light';
|
||||
import { RenderScene } from './render-scene';
|
||||
|
||||
export class SphereLight extends Light {
|
||||
|
||||
protected _needUpdate = false;
|
||||
|
||||
get position () {
|
||||
return this._pos;
|
||||
}
|
||||
@@ -20,6 +20,7 @@ export class SphereLight extends Light {
|
||||
|
||||
set range (range: number) {
|
||||
this._range = range;
|
||||
this._needUpdate = true;
|
||||
}
|
||||
|
||||
get range (): number {
|
||||
@@ -52,9 +53,10 @@ export class SphereLight extends Light {
|
||||
}
|
||||
|
||||
public update () {
|
||||
if (this._node) {
|
||||
if (this._node && (this._node.hasChangedFlags || this._needUpdate)) {
|
||||
this._node.getWorldPosition(this._pos);
|
||||
aabb.set(this._aabb, this._pos.x, this._pos.y, this._pos.z, this._range, this._range, this._range);
|
||||
this._needUpdate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ export class SpotLight extends Light {
|
||||
protected _aabb: aabb;
|
||||
protected _frustum: frustum;
|
||||
protected _angle: number = 0;
|
||||
protected _needUpdate = false;
|
||||
|
||||
get position () {
|
||||
return this._pos;
|
||||
@@ -37,6 +38,7 @@ export class SpotLight extends Light {
|
||||
|
||||
set range (range: number) {
|
||||
this._range = range;
|
||||
this._needUpdate = true;
|
||||
}
|
||||
|
||||
get range (): number {
|
||||
@@ -62,6 +64,7 @@ export class SpotLight extends Light {
|
||||
set spotAngle (val: number) {
|
||||
this._angle = val * 0.5;
|
||||
this._spotAngle = Math.cos(val * 0.5);
|
||||
this._needUpdate = true;
|
||||
}
|
||||
|
||||
get aabb () {
|
||||
@@ -81,9 +84,9 @@ export class SpotLight extends Light {
|
||||
}
|
||||
|
||||
public update () {
|
||||
if (this._node) {
|
||||
if (this._node && (this._node.hasChangedFlags || this._needUpdate)) {
|
||||
this._node.getWorldPosition(this._pos);
|
||||
this._dir = Vec3.transformQuat(_v3, _forward, this._node.getWorldRotation(_qt));
|
||||
Vec3.transformQuat(this._dir, _forward, this._node.getWorldRotation(_qt));
|
||||
Vec3.normalize(this._dir, this._dir);
|
||||
aabb.set(this._aabb, this._pos.x, this._pos.y, this._pos.z, this._range, this._range, this._range);
|
||||
|
||||
@@ -95,9 +98,10 @@ export class SpotLight extends Light {
|
||||
|
||||
// view-projection
|
||||
Mat4.multiply(_matViewProj, _matProj, _matView);
|
||||
Mat4.invert(_matViewProjInv, _matViewProj);
|
||||
// Mat4.invert(_matViewProjInv, _matViewProj);
|
||||
|
||||
this._frustum.update(_matViewProj, _matViewProjInv);
|
||||
this._needUpdate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -597,4 +597,4 @@ export class SplashScreen {
|
||||
private constructor () { };
|
||||
}
|
||||
|
||||
cc.SplashScreen = SplashScreen;
|
||||
cc.internal.SplashScreen = SplashScreen;
|
||||
|
||||
Reference in New Issue
Block a user