mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
fix GL2 buffer update (#5007)
This commit is contained in:
committed by
Weiliang Wang
parent
4bcb230d23
commit
a81e7269d2
@@ -102,7 +102,7 @@ export class SkeletalAnimationComponent extends AnimationComponent {
|
||||
}
|
||||
for (const stateName of Object.keys(this._nameToState)) {
|
||||
const state = this._nameToState[stateName] as SkeletalAnimationState;
|
||||
state.rebuildSocketAnimations(this._sockets);
|
||||
state.rebuildSocketCurves(this._sockets);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,11 +41,13 @@ export class SkeletalAnimationState extends AnimationState {
|
||||
public onPlay () {
|
||||
super.onPlay();
|
||||
for (const comp of this._targetNode!.getComponentsInChildren(SkinningModelComponent)) {
|
||||
comp.uploadAnimation(this.clip as SkeletalAnimationClip);
|
||||
if (comp.skinningRoot === this._targetNode) {
|
||||
comp.uploadAnimation(this.clip as SkeletalAnimationClip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public rebuildSocketAnimations (sockets: Socket[]) {
|
||||
public rebuildSocketCurves (sockets: Socket[]) {
|
||||
// TODO: curve reuse perhaps?
|
||||
// delete previous sockets
|
||||
if (!this._samplerSharedGroups.length) { return; }
|
||||
|
||||
+1
-1
@@ -762,7 +762,7 @@ class Game extends EventTarget {
|
||||
}
|
||||
}
|
||||
|
||||
useWebGL2 = false;
|
||||
// useWebGL2 = false;
|
||||
if (useWebGL2 && cc.WebGL2GFXDevice) {
|
||||
this._gfxDevice = new cc.WebGL2GFXDevice();
|
||||
} else if (cc.WebGLGFXDevice) {
|
||||
|
||||
@@ -708,9 +708,9 @@ export function WebGLCmdFuncUpdateBuffer (device: WebGLGFXDevice, gpuBuffer: Web
|
||||
|
||||
if (gpuBuffer.usage & GFXBufferUsageBit.UNIFORM) {
|
||||
if (buffer instanceof Float32Array) {
|
||||
gpuBuffer.vf32!.set(buffer, offset);
|
||||
gpuBuffer.vf32!.set(buffer, offset / Float32Array.BYTES_PER_ELEMENT);
|
||||
} else {
|
||||
gpuBuffer.vf32!.set(new Float32Array(buffer as ArrayBuffer), offset);
|
||||
gpuBuffer.vf32!.set(new Float32Array(buffer as ArrayBuffer), offset / Float32Array.BYTES_PER_ELEMENT);
|
||||
}
|
||||
} else if (gpuBuffer.usage & GFXBufferUsageBit.INDIRECT) {
|
||||
gpuBuffer.indirects = (buffer as IGFXIndirectBuffer).drawInfos;
|
||||
|
||||
@@ -68,7 +68,7 @@ const MAX_BINDING_SUPPORTED = 24; // from WebGL 2 spec
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* Uniform参数绑定。
|
||||
* Uniform 参数绑定。
|
||||
*/
|
||||
export enum UniformBinding {
|
||||
// UBOs
|
||||
@@ -93,7 +93,7 @@ export enum UniformBinding {
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 全局UBO。
|
||||
* 全局 UBO。
|
||||
*/
|
||||
export class UBOGlobal {
|
||||
|
||||
@@ -142,7 +142,7 @@ export class UBOGlobal {
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 阴影UBO。
|
||||
* 阴影 UBO。
|
||||
*/
|
||||
export class UBOShadow {
|
||||
public static MAT_LIGHT_PLANE_PROJ_OFFSET: number = 0;
|
||||
@@ -168,7 +168,7 @@ export const localBindingsDesc: Map<string, IInternalBindingDesc> = new Map<stri
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 本地UBO。
|
||||
* 本地 UBO。
|
||||
*/
|
||||
export class UBOLocal {
|
||||
public static MAT_WORLD_OFFSET: number = 0;
|
||||
@@ -192,7 +192,7 @@ localBindingsDesc.set(UBOLocal.BLOCK.name, {
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 前向灯光UBO。
|
||||
* 前向灯光 UBO。
|
||||
*/
|
||||
export class UBOForwardLight {
|
||||
public static MAX_SPHERE_LIGHTS = 2;
|
||||
@@ -236,27 +236,7 @@ export const JointUniformCapacity = 30;
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 蒙皮UBO。
|
||||
*/
|
||||
export class UBOSkinning {
|
||||
public static MAT_JOINT_OFFSET: number = 0;
|
||||
public static COUNT: number = JointUniformCapacity * 12;
|
||||
public static SIZE: number = UBOSkinning.COUNT * 4;
|
||||
|
||||
public static BLOCK: GFXUniformBlock = {
|
||||
binding: UniformBinding.UBO_SKINNING, name: 'CCSkinning', members: [
|
||||
{ name: 'cc_jointsData', type: GFXType.FLOAT4, count: JointUniformCapacity * 3 }, // DQ + scale
|
||||
],
|
||||
};
|
||||
}
|
||||
localBindingsDesc.set(UBOSkinning.BLOCK.name, {
|
||||
type: GFXBindingType.UNIFORM_BUFFER,
|
||||
blockInfo: UBOSkinning.BLOCK,
|
||||
});
|
||||
|
||||
/**
|
||||
* @zh
|
||||
* 蒙皮纹理信息UBO。
|
||||
* 骨骼贴图 UBO。
|
||||
*/
|
||||
export class UBOSkinningTexture {
|
||||
public static JOINTS_TEXTURE_INFO_OFFSET: number = 0;
|
||||
|
||||
@@ -101,7 +101,7 @@ export class SkinningModel extends Model {
|
||||
public setFrameID (val: number) {
|
||||
const { buffer, frameID } = this._jointsMedium;
|
||||
frameID[0] = val;
|
||||
buffer!.update(frameID, UBOSkinningTexture.JOINTS_FRAME_ID_OFFSET);
|
||||
buffer!.update(frameID, UBOSkinningTexture.JOINTS_FRAME_ID_OFFSET * Float32Array.BYTES_PER_ELEMENT);
|
||||
}
|
||||
|
||||
public getFrameID () {
|
||||
|
||||
Reference in New Issue
Block a user