Skip to content

Commit

Permalink
Merge branch 'v3.8.1' of github.com:cocos/cocos-engine into v3.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hana-alice committed Sep 20, 2023
2 parents d21dd29 + 0a5befb commit 3c3783d
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 116 deletions.
6 changes: 0 additions & 6 deletions cocos/physics/framework/deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,6 @@ removeProperty(RigidBody.prototype, 'RigidBody.prototype', [
},
]);

removeProperty(EConstraintType, 'EConstraintType.prototype', [
{
name: 'CONE_TWIST',
},
]);

/**
* Alias of [[RigidBody]]
* @deprecated Since v1.2
Expand Down
8 changes: 0 additions & 8 deletions cocos/physics/framework/physics-enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,6 @@ export enum EConstraintType {
* 铰链约束。
*/
HINGE,
/**
* @en
* Cone twist constraint.
* @zh
* 锥形扭转约束。
* @deprecated coneTwist is deprecated, please use configurable instead
*/
CONE_TWIST,
/**
* @en
* Fixed constraint.
Expand Down
17 changes: 2 additions & 15 deletions cocos/physics/framework/physics-selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-unsafe-return */
import { EDITOR, TEST } from 'internal:constants';
import { IBaseConstraint, IPointToPointConstraint, IHingeConstraint, IConeTwistConstraint, IFixedConstraint,
import { IBaseConstraint, IPointToPointConstraint, IHingeConstraint, IFixedConstraint,
IConfigurableConstraint } from '../spec/i-physics-constraint';
import {
IBoxShape, ISphereShape, ICapsuleShape, ITrimeshShape, ICylinderShape,
Expand Down Expand Up @@ -58,10 +58,6 @@ interface IPhysicsWrapperObject {
PlaneShape?: Constructor<IPlaneShape>,
PointToPointConstraint?: Constructor<IPointToPointConstraint>,
HingeConstraint?: Constructor<IHingeConstraint>,
/**
* @deprecated cone twist constraint is deprecated, please use configurable instead
*/
ConeTwistConstraint?: Constructor<IConeTwistConstraint>,
FixedConstraint?: Constructor<IFixedConstraint>,
ConfigurableConstraint?: Constructor<IConfigurableConstraint>,
}
Expand Down Expand Up @@ -236,10 +232,6 @@ enum ECheckType {
// JOINT //
PointToPointConstraint,
HingeConstraint,
/**
* @deprecated cone twist constraint is deprecated, please use configurable instead
*/
ConeTwistConstraint,
FixedConstraint,
ConfigurableConstraint,
// CHARACTER CONTROLLER //
Expand Down Expand Up @@ -422,7 +414,7 @@ function initColliderProxy (): void {

const CREATE_CONSTRAINT_PROXY = { INITED: false };

interface IEntireConstraint extends IPointToPointConstraint, IHingeConstraint, IConeTwistConstraint, IFixedConstraint, IConfigurableConstraint { }
interface IEntireConstraint extends IPointToPointConstraint, IHingeConstraint, IFixedConstraint, IConfigurableConstraint { }
const ENTIRE_CONSTRAINT: IEntireConstraint = {
impl: null,
initialize: FUNC,
Expand Down Expand Up @@ -488,11 +480,6 @@ function initConstraintProxy (): void {
return new selector.wrapper.HingeConstraint!();
};

CREATE_CONSTRAINT_PROXY[EConstraintType.CONE_TWIST] = function createConeTwistConstraint (): IConeTwistConstraint {
if (check(selector.wrapper.ConeTwistConstraint, ECheckType.ConeTwistConstraint)) { return ENTIRE_CONSTRAINT; }
return new selector.wrapper.ConeTwistConstraint!();
};

CREATE_CONSTRAINT_PROXY[EConstraintType.FIXED] = function createFixedConstraint (): IFixedConstraint {
if (check(selector.wrapper.FixedConstraint, ECheckType.FixedConstraint)) { return ENTIRE_CONSTRAINT; }
return new selector.wrapper.FixedConstraint!();
Expand Down
5 changes: 0 additions & 5 deletions cocos/physics/spec/i-physics-constraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,3 @@ export interface IConfigurableConstraint extends IBaseConstraint {
setBreakForce(v: number): void;
setBreakTorque(v: number): void;
}

/**
* @deprecated ConeTwistConstraint is deprecated, please use ConfigurableConstraint instead
*/
export type IConeTwistConstraint = IBaseConstraint
8 changes: 3 additions & 5 deletions cocos/render-scene/scene/submodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,10 @@ export class SubModel {
if (!this._globalPatches && pipelinePatches.length === 0) {
return;
} else if (pipelinePatches.length) {
if (this._globalPatches) {
if (this._globalPatches && pipelinePatches.length === this._globalPatches.length) {
const globalPatches = Object.entries(this._globalPatches);
if (pipelinePatches.length === globalPatches.length) {
const patchesStateUnchanged = JSON.stringify(pipelinePatches.sort()) === JSON.stringify(globalPatches.sort());
if (patchesStateUnchanged) return;
}
const patchesStateUnchanged = JSON.stringify(pipelinePatches.sort()) === JSON.stringify(globalPatches.sort());
if (patchesStateUnchanged) return;
}
}
this._globalPatches = pipeline.macros;
Expand Down
41 changes: 22 additions & 19 deletions cocos/rendering/pipeline-ubo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { builtinResMgr } from '../asset/asset-manager/builtin-res-mgr';
import { Texture2D } from '../asset/assets';
import { DebugViewCompositeType } from './debug-view';
import { getDescBindingFromName } from './custom/define';
import { Root } from '../root';

const _matShadowView = new Mat4();
const _matShadowProj = new Mat4();
Expand All @@ -47,7 +48,7 @@ const _tempVec3 = new Vec3();
export class PipelineUBO {
public static updateGlobalUBOView (window: RenderWindow, bufferView: Float32Array): void {
const director = cclegacy.director;
const root = director.root;
const root = director.root as Root;
const fv = bufferView;

const shadingWidth = Math.floor(window.width);
Expand Down Expand Up @@ -75,19 +76,21 @@ export class PipelineUBO {
}

const debugView = root.debugView;
fv[UBOGlobal.DEBUG_VIEW_MODE_OFFSET] = debugView.singleMode as number;

for (let i = 1; i <= 3; i++) {
for (let i = 0; i <= 3; i++) {
fv[UBOGlobal.DEBUG_VIEW_MODE_OFFSET + i] = 0.0;
}
for (let i = DebugViewCompositeType.DIRECT_DIFFUSE as number; i < DebugViewCompositeType.MAX_BIT_COUNT; i++) {
const offset = i >> 3;
const bit = i % 8;
fv[UBOGlobal.DEBUG_VIEW_MODE_OFFSET + 1 + offset] += (debugView.isCompositeModeEnabled(i) ? 1.0 : 0.0) * (10.0 ** bit);
}
if (debugView.isEnabled()) {
fv[UBOGlobal.DEBUG_VIEW_MODE_OFFSET] = debugView.singleMode as number;

for (let i = DebugViewCompositeType.DIRECT_DIFFUSE as number; i < (DebugViewCompositeType.MAX_BIT_COUNT as unknown as number); i++) {
const offset = i >> 3;
const bit = i % 8;
fv[UBOGlobal.DEBUG_VIEW_MODE_OFFSET + 1 + offset] += (debugView.isCompositeModeEnabled(i) ? 1.0 : 0.0) * (10.0 ** bit);
}

fv[UBOGlobal.DEBUG_VIEW_MODE_OFFSET + 3] += (debugView.lightingWithAlbedo ? 1.0 : 0.0) * (10.0 ** 6.0);
fv[UBOGlobal.DEBUG_VIEW_MODE_OFFSET + 3] += (debugView.csmLayerColoration ? 1.0 : 0.0) * (10.0 ** 7.0);
fv[UBOGlobal.DEBUG_VIEW_MODE_OFFSET + 3] += (debugView.lightingWithAlbedo ? 1.0 : 0.0) * (10.0 ** 6.0);
fv[UBOGlobal.DEBUG_VIEW_MODE_OFFSET + 3] += (debugView.csmLayerColoration ? 1.0 : 0.0) * (10.0 ** 7.0);
}
}

public static updateCameraUBOView (
Expand All @@ -96,7 +99,7 @@ export class PipelineUBO {
camera: Camera,
): void {
const scene = camera.scene ? camera.scene : cclegacy.director.getScene().renderScene;
const mainLight = scene.mainLight;
const mainLight = scene.mainLight as DirectionalLight;
const sceneData = pipeline.pipelineSceneData;
const ambient = sceneData.ambient;
const skybox = sceneData.skybox;
Expand Down Expand Up @@ -339,9 +342,9 @@ export class PipelineUBO {
if (shadowInfo.type === ShadowType.ShadowMap) {
let near = 0.1;
let far = 0;
let matShadowView;
let matShadowProj;
let matShadowViewProj;
let matShadowView: Mat4;
let matShadowProj: Mat4;
let matShadowViewProj: Mat4;
let levelCount = 0;
if (mainLight.shadowFixedArea || mainLight.csmLevel === CSMLevel.LEVEL_1 || !csmSupported) {
matShadowView = csmLayers.specialLayer.matShadowView;
Expand Down Expand Up @@ -403,10 +406,10 @@ export class PipelineUBO {

Mat4.perspective(
_matShadowProj,
(light as any).angle,
spotLight.angle,
1.0,
0.001,
(light as any).range,
spotLight.range,
true,
cap.clipSpaceMinZ,
cap.clipSpaceSignY,
Expand Down Expand Up @@ -564,6 +567,6 @@ export class PipelineUBO {
}
}

public destroy (): void {
}
// eslint-disable-next-line @typescript-eslint/no-empty-function
public destroy (): void {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ CCEffect %{
emissiveMap: { value: grey, editor: { displayName: EmissiveColorMap } }
alphaSource: { value: 1.0, editor: { slide: true, range: [0, 1.0], step: 0.001 } }
alphaSourceMap: { value: grey, editor: { parent: USE_OPACITY_MAP } }
alphaThreshold: { value: 0.5, target: albedoScaleAndCutoff.w, editor: { parent: USE_ALPHA_TEST, slide: true, range: [0, 1.0], step: 0.001 } }
alphaThreshold: { value: 0.5, editor: { parent: USE_ALPHA_TEST, slide: true, range: [0, 1.0], step: 0.001 } }
normalStrength: { value: 1.0, editor: { parent: USE_NORMAL_MAP, slide: true, range: [0, 1.0], step: 0.001 } }
normalMap: { value: normal }
- &forward-add
Expand Down Expand Up @@ -55,8 +55,8 @@ CCEffect %{
properties:
tilingOffset: { value: [1.0, 1.0, 0.0, 0.0] }
mainColor: { value: [1.0, 1.0, 1.0, 1.0], target: albedo, editor: { displayName: Albedo, type: color } }
albedoScale: { value: [1.0, 1.0, 1.0], target: albedoScaleAndCutoff.xyz }
alphaThreshold: { value: 0.5, target: albedoScaleAndCutoff.w, editor: { parent: USE_ALPHA_TEST } }
albedoScale: { value: 1.0, editor: { displayName: BaseWeight } }
alphaThreshold: { value: 0.5, editor: { parent: USE_ALPHA_TEST } }
mainTexture: { value: grey, target: albedoMap, editor: { displayName: AlbedoMap } }
alphaSource: { value: 1.0, editor: { slide: true, range: [0, 1.0], step: 0.001 } }
alphaSourceMap: { value: grey, editor: { parent: USE_OPACITY_MAP } }
Expand Down Expand Up @@ -96,7 +96,6 @@ CCProgram shared-ubos %{
uniform Constants {
vec4 tilingOffset;
vec4 albedo;
vec4 albedoScaleAndCutoff;
vec4 emissive;
float emissiveScale;
float occlusion;
Expand All @@ -105,6 +104,7 @@ CCProgram shared-ubos %{
float normalStrength;
float alphaSource;
float albedoScale;
float alphaThreshold;
float specularIntensity;
};
}%
Expand Down Expand Up @@ -237,7 +237,7 @@ CCProgram surface-fragment %{
#endif
#endif
#if USE_ALPHA_TEST
if (baseColor.a < albedoScaleAndCutoff.w) discard;
if (baseColor.a < alphaThreshold) discard;
#endif
return baseColor;
}
Expand Down Expand Up @@ -265,7 +265,7 @@ CCProgram surface-fragment %{
#endif
#endif

if (alpha < albedoScaleAndCutoff.w) discard;
if (alpha < alphaThreshold) discard;
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion native/cocos/platform/mac/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#import <MetalKit/MetalKit.h>

@interface View : NSView <CALayerDelegate>

- (int)getWindowId;
@property (nonatomic, assign) id<MTLDevice> device;

@end
16 changes: 16 additions & 0 deletions native/cocos/platform/mac/View.mm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ of this software and associated engine source code (the "Software"), a limited,
#import "platform/mac/modules/SystemWindow.h"
#import "platform/mac/modules/SystemWindowManager.h"

#include "SDL2/SDL.h"

static int MetalViewEventWatch(void* userData, SDL_Event*event) {
if (event->type == SDL_WINDOWEVENT && event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
@autoreleasepool {
auto *view = (__bridge View *)userData;
if ([view getWindowId] == event->window.windowID) {
[view viewDidChangeBackingProperties];
}
}
}
return 0;
}

@implementation View {
cc::MouseEvent _mouseEvent;
cc::KeyboardEvent _keyboardEvent;
Expand All @@ -50,6 +64,8 @@ - (CALayer *)makeBackingLayer {

- (instancetype)initWithFrame:(NSRect)frameRect {
if (self = [super initWithFrame:frameRect]) {
// View is used as a subview, so the resize message needs to be handled manually.
SDL_AddEventWatch(MetalViewEventWatch, (__bridge void*)(self));
[self.window makeFirstResponder:self];
int pixelRatio = [[NSScreen mainScreen] backingScaleFactor];
CGSize size = CGSizeMake(frameRect.size.width * pixelRatio, frameRect.size.height * pixelRatio);
Expand Down
6 changes: 3 additions & 3 deletions native/cocos/platform/mac/modules/Screen.mm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ of this software and associated engine source code (the "Software"), a limited,
#include "base/Macros.h"
#include "cocos/bindings/jswrapper/SeApi.h"
#include "platform/interfaces/modules/ISystemWindowManager.h"
#include "platform/interfaces/modules/ISystemWindow.h"
#include "platform/mac/modules/SystemWindow.h"
#include "application/ApplicationManager.h"
namespace cc {

Expand All @@ -52,8 +52,8 @@ of this software and associated engine source code (the "Software"), a limited,
global->getProperty("devicePixelRatio", &devicePixelRatioVal);
return devicePixelRatioVal.isNumber() ? devicePixelRatioVal.toFloat() : 1.F;
#else
auto* window = CC_GET_MAIN_SYSTEM_WINDOW();
NSWindow* nsWindow = reinterpret_cast<NSWindow*>(window->getWindowHandle()) ;
auto* systemWindow = static_cast<SystemWindow*>(CC_GET_MAIN_SYSTEM_WINDOW());
auto* nsWindow = systemWindow->getNSWindow();
return [nsWindow backingScaleFactor];
#endif
}
Expand Down
8 changes: 4 additions & 4 deletions native/cocos/platform/mac/modules/SystemWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ of this software and associated documentation files (the "Software"), to deal

#include "platform/mac/modules/SystemWindow.h"
#include "platform/mac/View.h"

#include "base/Log.h"
#include "base/Macros.h"

Expand Down Expand Up @@ -57,16 +58,15 @@ of this software and associated documentation files (the "Software"), to deal
void SystemWindow::initWindowProperty(SDL_Window* window, const char *title, int x, int y, int w, int h) {
CC_ASSERT(window != nullptr);
auto* nsWindow = reinterpret_cast<NSWindow*>(SDLHelper::getWindowHandle(window));
NSRect rect = NSMakeRect(x, y, w, h);
NSString *astring = [NSString stringWithUTF8String:title];
nsWindow.title = astring;
// contentView is created internally by sdl.
NSView *view = nsWindow.contentView;
auto* newView = [[View alloc] initWithFrame:rect];
auto* newView = [[View alloc] initWithFrame:view.frame];
[view addSubview:newView];
[nsWindow.contentView setWantsBestResolutionOpenGLSurface:YES];
[nsWindow makeKeyAndOrderFront:nil];

_windowHandle = reinterpret_cast<uintptr_t>(nsWindow.contentView) ;
_windowHandle = reinterpret_cast<uintptr_t>(newView);

auto dpr = [nsWindow backingScaleFactor];
_width = w * dpr;
Expand Down
7 changes: 0 additions & 7 deletions native/cocos/renderer/gfx-metal/MTLSwapchain.mm
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ of this software and associated engine source code (the "Software"), a limited,
if (!layer.device) {
layer.device = MTLCreateSystemDefaultDevice();
}
#elif CC_PLATFORM == CC_PLATFORM_MACOS
CAMetalLayer *layer = nullptr;
auto *view = (CCView *)info.windowHandle;
if(view && view.subviews.count > 0) {
NSView* subView = view.subviews[0];
layer = static_cast<CAMetalLayer *>(subView.layer);
}
#else
auto *view = (CCView *)info.windowHandle;
CAMetalLayer *layer = static_cast<CAMetalLayer *>(view.layer);
Expand Down
Loading

0 comments on commit 3c3783d

Please sign in to comment.