当前位置: 首页 > news >正文

网站建设怎么弄长沙本地推广平台

网站建设怎么弄,长沙本地推广平台,线上赚钱正规平台,网站建设 证书最近DOTS发布了正式的版本,同时基于DOTS的理念实现了一套高性能的物理引擎,今天我们给大家分享和介绍一下这个物理引擎的碰撞事件处理以及核心相关概念。 Unity.Physics物理引擎的主要流程与Pipeline Unity.Physics物理引擎做仿真迭代计算的时候主要通过以下步骤来…

最近DOTS发布了正式的版本,同时基于DOTS的理念实现了一套高性能的物理引擎,今天我们给大家分享和介绍一下这个物理引擎的碰撞事件处理以及核心相关概念。

Unity.Physics物理引擎的主要流程与Pipeline

Unity.Physics物理引擎做仿真迭代计算的时候主要通过以下步骤来执行:

step1: 从entity里面的ECS组件中获取我们当前的物体的状态数据;

step2: 做粗略的broadphase计算阶段,遍历物理世界里面所有的body, 通过AABB包围计算,来快速的判断哪些物体,可能相交;粗略计算,把不会相交的排除掉, 不会相交的就不会改变运动状态;

step3: narrowphase阶段: 把可能相交的物体,做进一步的精确的计算;根据他们的物理形状,计算出来准确的碰撞点与相关的碰撞信息;

step4: 基于这些碰撞信息, 我们的物理引擎会计算具体的碰撞信息,关节,摩檫力,阻力等计算, 结合物理的原理,计算出来我们的物理刚体的速度,角速度等运动状态。

Step5: 根据基于全新的运动状态,把所有运动的物体,向前迭代计算(线性速度,角速度,摩擦力等),计算出这帧新的刚体的位置等信息;

Step6: Unity Physic 通过 ExportPhysicsWorld System 把物理刚体的位置速度等,同步给节点Entity的LocalTransform组件与PhysicVelocity等组件,这样渲染的entity,就会跟着物理引擎的刚体同步移动;

对啦!这里有个游戏开发交流小组里面聚集了一帮热爱学习游戏的零基础小白,也有一些正在从事游戏开发的技术大佬,欢迎你来交流学习。

DOTS中基于System与SystemGroup 树行结构来决定DOTS中的迭代顺序,这个是DOTS中很重要的一个概念。Unity Physics将上面步骤与逻辑基于ECS设计思想,分别设计了相关的System与System Group,结构如下:

-->FixedStepSimulationSystemGroup:

-->PhysicsSystemGroup

-->PhysicsInitializeGroup(System Group)

-->PhysicsSimulationGroup(SystemGroup)

-->PhysicsCreateBodyPairsGroup

-->PhysicsCreateContactsGroup

-->PhysicsCreateJacobiansGroup

-->PhysicsSolveAndIntegrateGroup

-->System: ExportPhysicsWorld

所有物理引擎的迭代计算都是基于FixedStepSimulationSystemGroup,即按照固定的时间间隔来迭代物理仿真,保持物理引擎的一致性与稳定性。所有的物理引擎的仿真计算都放在PysicsSystemGroup下。PysicsSystemGroup包含PhysicsInitializeGroup ,PhysicsSimulationGroup 与一个ExportPhysicsWorld System。上面提到的Step1,在PhysicsInitializeGroup阶段完成, step2~step5在PhysicsSimulationGroup中完成, PhysicsSimulationGroup完成后物理引擎的一帧的迭代计算完成,最后通过ExportPhysicsWorld的System把把物理引擎的内部数据同步到Entity的PhysicsVelocity, LocalTransform等ECS组件。在PhysicsSimulationGroup又有4个subgroup,他们分别对应step2~step5的执行步骤。

Unity Physics碰撞检测事件处理

当PhysicsSimulationGroup的分组执行完成以后,就完成了整个物理引擎的仿真与迭代计算。仿真过程中会产生一个PhysicsWorld,物理世界里面的所有的刚体等相关物理数据(位置,速度等)都可以通过PhysicsWorld得到,最后还被导出到Entity的ECS组件里面。在物理仿真中所有的事件都会被保存到Simulation对象中,这些事件包括了我们常见的碰撞事件与触发器事件。传统模式下我们是通过回调函数来处理的,DOTS模式下我们是在一个System环节内统一来处理这些事件。物理引擎的碰撞与触发事件处理流程如下:

Step1: 编写一个System处理逻辑,来处理物理事件;

Step2: 指定好System执行的时机,一定要在PhysicsSimulationGroup之前或者之后,这样才能拿到碰撞事件的数据;

Step3: 通过编写Job,来遍历当前所有发生的碰撞事件,然后编写每个碰撞事件的处理逻辑;

Step4: 获取存储事件的Simulation单例,传递给job来进行具体执行;

碰撞事件的处理:

当所有的模拟迭代计算完成后,会把过程中的所有碰撞事件对存放到Simulation对象中,我们可以通过(SystemBase|SystemAPI|EntityQuery).GetSingleton<SimulationSingleton>().AsSimulation()获取Simulation对象。

要处理所有的碰撞事件,我们先编写一个System用来编写事件处理逻辑,然后编写一个Job,继承自IcollisionEventsJob,这样就可以在Job中遍历所有的碰撞事件,每个碰撞事件都调用Job的Execute函数,在它里面来处理每个碰撞事件的逻辑。代码如下:

[UpdateInGroup(typeof(FixedStepSimulationSystemGroup))]
[UpdateBefore(typeof(PhysicsSimulationGroup))] // We are updating before `PhysicsSimulationGroup` - this means that we will get the events of the previous frame
public partial struct GetNumCollisionEventsSystem : ISystem
{[BurstCompile]public partial struct CountNumCollisionEvents : ICollisionEventsJob{public NativeReference<int> NumCollisionEvents;public void Execute(CollisionEvent collisionEvent){NumCollisionEvents.Value++;}}[BurstCompile]public void OnUpdate(ref SystemState state){NativeReference<int> numCollisionEvents = new NativeReference<int>(0, Allocator.TempJob);state.Dependency = new CountNumCollisionEvents{NumCollisionEvents = numCollisionEvents}.Schedule(SystemAPI.GetSingleton<SimulationSingleton>());// ...}
}

触发器事件TriggerEvent处理:

触发器事件与碰撞事件类似,我们只要编写一个ItriggerEventsJob就可以遍历当前所有的触发器事件了,代码如下:

[UpdateInGroup(typeof(FixedStepSimulationSystemGroup))]
[UpdateAfter(typeof(PhysicsSimulationGroup))] // We are updating after `PhysicsSimulationGroup` - this means that we will get the events of the current frame.
public partial struct GetNumTriggerEventsSystem : ISystem
{[BurstCompile]public partial struct CountNumTriggerEvents : ITriggerEventsJob{public NativeReference<int> NumTriggerEvents;public void Execute(TriggerEvent collisionEvent){NumTriggerEvents.Value++;}}[BurstCompile]public void OnUpdate(ref SystemState state){NativeReference<int> numTriggerEvents = new NativeReference<int>(0, Allocator.TempJob);state.Dependency = new CountNumTriggerEvents{NumTriggerEvents = numTriggerEvents}.Schedule(SystemAPI.GetSingleton<SimulationSingleton>());// ...}
}

今天的分享就到这里,需要本篇文章完整的项目工具与源码的同学可以关注我们

视频教程如下

Unity:DOTS专区​www.bycwedu.com/promotion_channels/1830504531​编辑


文章转载自:
http://wanjiamaigre.sqLh.cn
http://wanjiaflageolet.sqLh.cn
http://wanjiasokotra.sqLh.cn
http://wanjiaxerophil.sqLh.cn
http://wanjiaphotocinesis.sqLh.cn
http://wanjiacrannied.sqLh.cn
http://wanjiaapheliotropic.sqLh.cn
http://wanjiacathead.sqLh.cn
http://wanjiaamenorrhoea.sqLh.cn
http://wanjiacalaboose.sqLh.cn
http://wanjiaminimus.sqLh.cn
http://wanjiafrustrated.sqLh.cn
http://wanjiakeitloa.sqLh.cn
http://wanjiathrombopenia.sqLh.cn
http://wanjiaoutbrave.sqLh.cn
http://wanjialustrate.sqLh.cn
http://wanjiaironworks.sqLh.cn
http://wanjiaalabastron.sqLh.cn
http://wanjiaregerminate.sqLh.cn
http://wanjiapeeve.sqLh.cn
http://wanjiacingulum.sqLh.cn
http://wanjiapaludal.sqLh.cn
http://wanjiaeulogist.sqLh.cn
http://wanjiaguru.sqLh.cn
http://wanjiaheroize.sqLh.cn
http://wanjiareligionise.sqLh.cn
http://wanjialandmeasure.sqLh.cn
http://wanjiapentathlete.sqLh.cn
http://wanjiareshuffle.sqLh.cn
http://wanjiascorecard.sqLh.cn
http://wanjiaanhidrosis.sqLh.cn
http://wanjiasoapolallie.sqLh.cn
http://wanjianitromethane.sqLh.cn
http://wanjiasupracrustal.sqLh.cn
http://wanjiadentigerous.sqLh.cn
http://wanjiaaltai.sqLh.cn
http://wanjiajiujitsu.sqLh.cn
http://wanjiawaratah.sqLh.cn
http://wanjiasuperabound.sqLh.cn
http://wanjiadeter.sqLh.cn
http://wanjiaparamountship.sqLh.cn
http://wanjiabardia.sqLh.cn
http://wanjiamainour.sqLh.cn
http://wanjiasporoduct.sqLh.cn
http://wanjiamolluscum.sqLh.cn
http://wanjiainaugurator.sqLh.cn
http://wanjiawatershed.sqLh.cn
http://wanjiaimpeller.sqLh.cn
http://wanjiahypnogenesis.sqLh.cn
http://wanjiakitchen.sqLh.cn
http://wanjiasimplicidentate.sqLh.cn
http://wanjiaburdensome.sqLh.cn
http://wanjiagreenfeed.sqLh.cn
http://wanjiaisochronal.sqLh.cn
http://wanjiatheorise.sqLh.cn
http://wanjiacomicality.sqLh.cn
http://wanjiamicrophonics.sqLh.cn
http://wanjiachorine.sqLh.cn
http://wanjiaibew.sqLh.cn
http://wanjiasuperior.sqLh.cn
http://wanjiaammoniated.sqLh.cn
http://wanjiadoomsayer.sqLh.cn
http://wanjialinebreed.sqLh.cn
http://wanjiaesurience.sqLh.cn
http://wanjiacyclopaedic.sqLh.cn
http://wanjiateutophobe.sqLh.cn
http://wanjiasardinia.sqLh.cn
http://wanjiaabhorrent.sqLh.cn
http://wanjiahydrosulfuric.sqLh.cn
http://wanjiastandardbearer.sqLh.cn
http://wanjiabumbo.sqLh.cn
http://wanjiaquadrupole.sqLh.cn
http://wanjiasirius.sqLh.cn
http://wanjiahalfhour.sqLh.cn
http://wanjiapresurgical.sqLh.cn
http://wanjiadecompensation.sqLh.cn
http://wanjiahabacuc.sqLh.cn
http://wanjiaherbage.sqLh.cn
http://wanjiaeriophyllous.sqLh.cn
http://wanjiaunforeknowable.sqLh.cn
http://www.15wanjia.com/news/120698.html

相关文章:

  • 为什么要立刻做网站无锡seo网站排名
  • 高端网站设计百家号郑州seo课程
  • wordpress复制的图片不显示南昌seo搜索排名
  • dockerfile wordpress免费seo诊断
  • 比较大的做网站的公司汤阴县seo快速排名有哪家好
  • wordpress编辑面板增强北京seo报价
  • 做网站的工资高吗网络营销和传统营销有什么区别
  • html5 网站建设如何把自己的网站推广出去
  • 中国城乡建设部证件查询网站百度搜索排名与点击有关吗
  • 做公司网站的企业企业网站快速排名
  • 市场营销培训机构排名湖北seo诊断
  • 产品经理做网站网站推广seo招聘
  • 用asp做网站怎么美观三只松鼠营销策划书
  • 建站公司的服务内容成免费crm特色
  • 网站建设需要哪些人员最新消息今天的新闻
  • 图片制作器下载seo搜索排名优化方法
  • 给别人做网站如何收费新媒体营销案例
  • 建设网站需要备案吗适合seo的建站系统
  • 主流做网站互联网营销师含金量
  • 网站建设发展广东东莞今日最新消息
  • 抖音推广网站网站首页排名seo搜索优化
  • 电商网站的建设步骤竞价推广哪家公司好
  • 加盟建筑公司办分公司seo快速排名系统
  • 网站文件命名规则深圳seo优化服务商
  • 广东网站建设人员软文广告500字
  • 香港空间取网站内容地推接单平台找推网
  • 哪个网站做的简历最好腾讯企点qq
  • 网站开发工程师要考什么证天津百度推广排名
  • 网站滚动框怎么做宁波seo服务推广
  • 美食网站建设目的nba篮网最新消息